如何从左翻转?
UIImageView * frontImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"view.png"]];
UIView * containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = self.view.center;
[self.view addSubview:containerView];
[containerView addSubview:frontImageView];
UIImageView * backImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"view.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:containerView
cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];
我想翻转容器视图,但它不起作用。
UIImageView * frontImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"view.png"]];
UIView * containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = self.view.center;
[self.view addSubview:containerView];
[containerView addSubview:frontImageView];
UIImageView * backImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"view.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:containerView
cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];
i wanna Flip the containerView,but it doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一篇关于同一问题的类似帖子。 @Jason Harwig 建议你尝试:
编辑:查看另一篇文章,似乎在提交动画之前添加子视图是问题所在。你为什么不尝试一下呢?
希望有帮助!
This is a similar post about the same problem. @Jason Harwig suggests that you try:
EDIT: Looking at another post, it seems as though adding the subview BEFORE commiting the animations is the problem. Why don't you try that?
Hope that Helps!
不要使用
在这个函数中。发生的事情是在动画发生之前,您的视图将从超级视图中删除。因此,没有动画。而是使用这个。
并制定另一种方法,
dont use
in this function. What happens is before the animations happen, your view gets removed from superview. Hence, no animation. Instead use this.
and make another method,
正确设置containerView的框架。您将其设置为不正确的frontImageView.bounds。
Set containerView's frame properly.You have set it to frontImageView.bounds that is not right.