开发者社区> 问答> 正文

uiview翻转动画轴心问题

我在view1的背面加上view2,view1翻转过来就显示view2,利用uiview动画UIViewAnimationOptionTransitionFlipFromRight实现。
问题是view1翻转的时候不是按照view1的中间轴心翻转,而是按self。view的轴心翻转,请问怎么解决这个问题?

[self.view1 sendSubviewToBack:self.view2]
[UIView transitionFromView:(self.view1)
toView:(self.view2)
duration: 2
options: UIViewAnimationOptionTransitionFlipFromLeft+UIViewAnimationOptionCurveEaseInOut
completion:^(BOOL finished) {
if (finished) {

                }
            }

];

展开
收起
a123456678 2016-07-27 15:45:46 1901 0
1 条回答
写回答
取消 提交回答
  •  UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
    
        [self.view addSubview:containerView];
    
        UIView *fromView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerView.frame.size.width, containerView.frame.size.height)];
        fromView.backgroundColor = [UIColor blueColor];
        UIView *toView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerView.frame.size.width, containerView.frame.size.height)];
        toView.backgroundColor = [UIColor purpleColor];
        [containerView addSubview:fromView];
    
        [self.view addSubview:fromView];
    
        [CATransaction flush];
    
        [UIView transitionFromView:fromView toView:toView duration:0.4f options:UIViewAnimationOptionTransitionFlipFromLeft completion:NULL];
    2019-07-17 20:00:44
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载