【发布时间】:2017-11-20 16:25:42
【问题描述】:
@interface ViewController
@property(weak) IBOutlet UIView *blackView;
@end
(1) 首先我尝试使用动画块
- (IBAction) buttonHitted:(id)sender
{
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationBeginsFromCurrentStatus: NO];
self.blackView.center = CGPointMake(UIScreen.mainScreen.bounds.size.width - self.blackView.center.x, self.blackView.center.y);
[UIView commitAnimations];
}
而且动画总是从当前状态开始,我不知道为什么很长时间。
(2)然后我尝试使用代码块,同样可悲。
- (IBAction) buttonHitted:(id)sender
{
[UIView animateWithDuration:2.0 delay:0.0 options:0
animations:^(void)
{
self.blackView.center = CGPointMake(UIScreen.mainScreen.bounds.size.width - self.blackView.center.x, self.blackView.center.y);
}
completion:nil];
}
//Options to 0, indicating that UIViewAnimationOptionBeginFromCurrentState not setted
我只是想知道为什么动画总是从当前状态开始。我检查了视图的属性,它总是当前动画的最后一个值。
【问题讨论】:
标签: ios objective-c animation uiview