开发者社区 问答 正文

iphone--视图移动动画

我需要点击按钮时往右移动视图,写的代码没有实现:

UIView* view = [self.view viewWithTag:100];
if (!view) {
    NSLog(@"nil");
}

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

                 }
                 completion:^(BOOL finished){

                 }
 ];

展开
收起
爵霸 2016-03-25 13:55:32 1793 分享 版权
1 条回答
写回答
取消 提交回答
  •   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");
    
             }];
    2019-07-17 19:14:10
    赞同 展开评论
问答标签:
问答地址: