ios – iPhone视图移动动画

前端之家收集整理的这篇文章主要介绍了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");

         }];
原文链接:https://www.f2er.com/iOS/335000.html

猜你在找的iOS相关文章