ios – iPhone视图移动动画

当我点击一个按钮时,我想将一个视图移动到右边.
我写了一些东西,但它不工作;
UIView* view = [self.view viewWithTag:100];
if (!view) {
    NSLog(@"nil");
}

[UIView animateWithDuration:0.3f 
                 animations:^{
                     [view setTransform:CGAffineTransformMakeTranslation(-100,0)];

                 }
                 completion:^(BOOL finished){

                 }
 ];

解决方法

尝试这段代码;
UIView* view = [self.view viewWithTag:100];
  [UIView animateWithDuration:0.5
                              delay:0.1
                            options: UIViewAnimationCurveEaSEOut
                         animations:^
         {                 
             CGRect frame = view.frame;
             frame.origin.y = 0;
             frame.origin.x = (-100);
             view.frame = frame;
         }
                         completion:^(BOOL finished)
         {
             NSLog(@"Completed");

         }];

以上是来客网为你收集整理的ios – iPhone视图移动动画全部内容,希望文章能够帮你解决ios – iPhone视图移动动画所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。