【发布时间】:2013-02-15 22:39:59
【问题描述】:
想要通过改变 UIView 的高度和位置来为它设置动画。第一个动画跳跃?我在 Storyboards 中将 UIView (theView) 的大小设置为 216 的高度。因此应用程序加载并显示 theView。我单击 theView,它的高度迅速跃升至 200+ 像素,然后按应有的动画效果?
- (void)singleTapAction:(UIGestureRecognizer *)singleTap {
UIView *view = singleTap.view;
[UIView animateWithDuration:1.2 delay:0 options:UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{
CGRect theFrame = self.theView.frame;
theFrame.size.height += 100.f; <!-- when it hits here the view jumps then animates
self.theView.frame = theFrame;
}
completion:^(BOOL finished) {
if(finished){
[UIView animateWithDuration:1.2 delay:0 options:UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{
CGRect theFrame = self.theView.frame;
theFrame.origin.y -= 100.f;
self.theView.frame = theFrame;
}
completion:^(BOOL finished) {
NSLog(@"animations complete");
}];
}
}];
}
【问题讨论】:
-
不确定是否理解您的问题。顺便说一句,您在 UIView::animate 中没有“自动反转”选项。
-
@Vinzius 你是对的。
标签: ios objective-c uiview caanimation