在iphone中制作弹出图像
我正在做一个小游戏,如果你赢了,它会显示你的形象。图像大小为全屏。我想让它成为当我点击它时,它会删除和活动,或者在iphone中制作弹出图像,iphone,objective-c,cocoa-touch,ipad,Iphone,Objective C,Cocoa Touch,Ipad,我正在做一个小游戏,如果你赢了,它会显示你的形象。图像大小为全屏。我想让它成为当我点击它时,它会删除和活动,或者viewController做一些事情并重新开始 我有一个想法,我可以添加点击手势识别器,但如何才能弹出一个图像,在后台停止活动,然后在录制后做一些事情并重新启动控制器 最好的问候要“弹出”图像,您只需创建一个UIButton,将图像作为背景,并将其隐藏,要弹出图像,您只需使其可见即可 只需将按钮连接到您希望在按下按钮时调用的方法。子类UIView可创建显示所需内容的PopupView
viewController
做一些事情并重新开始
我有一个想法,我可以添加点击手势识别器
,但如何才能弹出一个图像,在后台停止活动,然后在录制后做一些事情并重新启动控制器
最好的问候要“弹出”图像,您只需创建一个UIButton,将图像作为背景,并将其隐藏,要弹出图像,您只需使其可见即可
只需将按钮连接到您希望在按下按钮时调用的方法。子类UIView可创建显示所需内容的PopupView。覆盖此功能:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self setHidden:TRUE];
[self removeFromSuperview];
}
我这里有一个代码取自facebook示例iphone代码。它会前后弹出一个带有动画的视图
只需创建一个自定义按钮,链接它,在里面添加图像,调整框架/位置,然后隐藏它
-(void) zoomInWorld{
buttonImage.hidden = NO;
buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];
}
- (void)bounce1AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.15];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
buttonImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
[UIView commitAnimations];
}
- (void)bounce2AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.15];
//[UIView setAnimationDidStopSelector:@selector(nextAction)];
buttonImage.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
[a addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlStateNormal];
}