【发布时间】:2014-04-28 10:06:40
【问题描述】:
目前我正在创建一个应用程序,当您第一次启动它时,有一些介绍文本和 2 个按钮。 1个按钮跳过教程,另一个按钮做教程。我希望这 2 个按钮和那些标签在一定时间后出现并带有淡入动画。谁能给我一些代码示例?我已经尝试过搜索,但结果对我没有帮助。
我更新了一些代码。现在看起来像这样:
.h 文件:
@interface startViewController : UIViewController {
IBOutlet UIButton *notourb;
IBOutlet UIButton *tourb;
IBOutlet UILabel *welcomeLabel;
}
- (void)shownotourb;
- (void)showtourb;
- (void)showwLabel;
还有 .m 文件(我将只显示按钮中的代码,因为我想出了如何以另一种方式制作标签):
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:@selector(shownotourb) withObject:nil afterDelay:2.0];
[self performSelector:@selector(showtourb) withObject:nil afterDelay:2.5];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)shownotourb {
[UIView animateWithDuration:10.0
delay:1.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
[self.view addSubview:notourb];
}
completion:^(BOOL finished){}];
}
- (void)showtourb {
[UIView animateWithDuration:10.0
delay:1.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
[self.view addSubview:tourb];
}
completion:^(BOOL finished){}];
}
【问题讨论】:
-
检查
CABasicAnimation概念,这将帮助您了解淡入淡出动画。并延迟performSelector:withObject:afterDelay:.. -
@Niclas 检查我的答案。