【发布时间】:2017-02-21 20:49:21
【问题描述】:
我有一个简单的动画,它一次一个地淡入多个标签。但是不知道是不是可以用这个逻辑来减少代码呢?
[UIView animateWithDuration:0.50f animations:^{
[_latLabel setAlpha:0.9f];
[_firstLat setAlpha:0.9f];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.50f animations:^{
[_lonLabel setAlpha:0.9f];
[_firstLon setAlpha:0.9f];
}completion:^(BOOL finished) {
[UIView animateWithDuration:0.50f animations:^{
[_speedLabel setAlpha:0.9f];
[_firstSpeed setAlpha:0.9f];
}completion:^(BOOL finished) {
[UIView animateWithDuration:0.50f animations:^{
[_realNorthLabel setAlpha:0.9f];
[_firstReal setAlpha:0.9f];
}completion:^(BOOL finished) {
[UIView animateWithDuration:0.50f animations:^{
[_magneticNorthLabel setAlpha:0.9f];
[_firstMagnetic setAlpha:0.9f];
}];
}];
}];
}];
}];
【问题讨论】:
-
使用延迟启动的函数
-
嗯,我正在尝试你的建议,但我得到了很多错误......
-
所以你构建了一个带有延迟启动参数的函数,但你得到了一个错误,你是如何做到的
-
你的意思是用这个? [UIView animateWithDuration: 延迟: 选项: 动画: 完成:]
-
我这样做但结果不一样:[UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseOut animations:^{[_latLabel setAlpha:0.9f]; [_firstLon setAlpha:0.9f]; [_speedLabel setAlpha:0.9f]; [_firstSpeed setAlpha:0.9f]; [_realNorthLabel setAlpha:0.9f]; [_firstReal setAlpha:0.9f]; [_magneticNorthLabel setAlpha:0.9f]; [_firstMagnetic setAlpha:0.9f]; } 完成:^(BOOL 完成){ nil; }];
标签: ios objective-c animation