wh1*_*t1k 5 iphone animation objective-c uiview
我遇到了iPhone动画块的奇怪问题.这段代码:
[UIView animateWithDuration:2 delay: 0 options: 0 animations:
^(void) { [controller setBackgroundColor: [UIColor blueColor]]; }
completion: nil];
[UIView animateWithDuration:2 delay: 2 options: 0 animations:
^(void) { [controller setBackgroundColor: [UIColor redColor]]; }
completion: nil];
Run Code Online (Sandbox Code Playgroud)
立即将背景设置为红色,而不通过蓝色状态.对于这段代码,即使是同样的事情:
[UIView animateWithDuration:2 delay: 0 options: 0 animations:
^(void) { [controller setBackgroundColor: [UIColor blueColor]]; }
completion:
^(BOOL wrwg) {
[UIView animateWithDuration:2 delay: 2 options: 0 animations:
^(void) { [controller setBackgroundColor: [UIColor redColor]]; }
completion: nil];
}];
Run Code Online (Sandbox Code Playgroud)
也就是说,我试图在第一个动画完成之后运行第二个动画.有什么问题?
小智 8
我有同样的问题.使shure控制器的类型为UIView,否则动画块被解释为"无动画执行",因此被跳过并呈现下一个动画.
也看看这篇文章,我问同样的问题(由我解决):http: //www.iphonedevsdk.com/forum/iphone-sdk-development/64451-animation-one-after-another.html#post265531
物业backgroundColor是不是在UIView的动画.相反,使用backgroundColor视图图层的属性:
#import <QuartzCore/QuartzCore.h> // don't forget to link this library in project settings
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimatingOptionBeginFromCurrentState
animations:^(void){
controller.layer.backgroundColor = [UIColor blueColor].CGColor;
}
completion:NULL];
Run Code Online (Sandbox Code Playgroud)
PS正如以前的帖子所指出的那样,确保你controller的继承自UIView.如果它是继承的UIViewController,请controller.view改用.
| 归档时间: |
|
| 查看次数: |
13995 次 |
| 最近记录: |