我在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) {
}
}
];
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];
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。