我需要一个贴纸页面,有人可以随意引入任意数量的贴纸并放在页面上。用户应该可以移动任何贴纸。我只能移动引入的贴纸,而不是viewDidLoad方法带来的保存贴纸。
开始接触:
UITouch * touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view];
if (location.x < image0.frame.size.width + image0.frame.origin.x && location.y < image0.frame.size.height + image0.frame.origin.y && location.x > image0.frame.origin.x && location.y > image0.frame.origin.y)
{
[image0 removeFromSuperview];
image0 = nil;
image0 =[[UIImageView alloc] initWithFrame:CGRectMake(location.x - 25,location.y-25, 50, 50)];
image0.image =[UIImage imageNamed:sticker.stickerFilePath];
[self.view addSubview:image0];
}
在viewDidLoad中,正在引入类中保存的贴纸:
stickerArray = [self loadStickerData]; allStickers = [[NSMutableArray alloc] initWithCapacity:10];
sticker=[self.childClass.stickerInfo objectAtIndex:0];
float x = sticker.xLocationOfSticker, y = sticker.yLocationOfSticker, w =sticker.stickerWidth, h=sticker.stickerHeight;
image0 =[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)];
image0.image=[UIImage imageNamed:sticker.stickerFilePath];
[self.view addSubview:image0];