开发者

iOS: remove my random placed image

开发者 https://www.devze.com 2023-03-19 05:32 出处:网络
I\'m using this to display a image randomly on the iPhone screen. -(IBAction)gunshot { UIImageView *img = [[UIImageView alloc]

I'm using this to display a image randomly on the iPhone screen.

-(IBAction)gunshot {
UIImageView *img = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"gunshot.png"]];
img.frame = CGRectMake(0, 0, 85, 63);
img.center = CGPointMake(random() % 350, random() % 350);
[self.view addSubview:img];
[img release];
}

Now my "problem" is to remove the images that pops-up on the screen after lets say 2 sec. Hope you can help me and thanks in ad开发者_C百科vance.


[img performSelector:@selector(removeFromSuperview) withObject:self afterDelay:2.0];
0

精彩评论

暂无评论...
验证码 换一张
取 消