0

通过更改 UIView 的高度和位置来为 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");
                                          }];
                     }
                 }];

}

4

1 回答 1

0

尝试移动线条

CGRect theFrame = self.theView.frame;
theFrame.size.height += 100.f;  <!-- when it hits here the view jumps then animates

块外。将它放在调用动画方法之前。

于 2013-02-16T04:00:11.013 回答