如何从左翻转?

发布于 2024-12-03 06:08:57 字数 973 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

誰認得朕 2024-12-10 06:08:57

这是一篇关于同一问题的类似帖子。 @Jason Harwig 建议你尝试:

尝试在动画过渡视图中使用self.view.superview
显示更多信息:

编辑:查看另一篇文章,似乎在提交动画之前添加子视图是问题所在。你为什么不尝试一下呢?

希望有帮助!

This is a similar post about the same problem. @Jason Harwig suggests that you try:

Try using self.view.superview in the animation transition view of the
showMoreInfo:

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!

情感失落者 2024-12-10 06:08:57

不要使用

[frontImageViewremoveFromSuperview];

在这个函数中。发生的事情是在动画发生之前,您的视图将从超级视图中删除。因此,没有动画。而是使用这个。

[UIView setAnimationDidStopSelector:@selector(removeImageView)];

并制定另一种方法,

-(void) removeImageView
{
        if([yourImageView superview])
            [yourImageView removeFromSuperview];
}

dont use

[frontImageView removeFromSuperview];

in this function. What happens is before the animations happen, your view gets removed from superview. Hence, no animation. Instead use this.

[UIView setAnimationDidStopSelector:@selector(removeImageView)];

and make another method,

-(void) removeImageView
{
        if([yourImageView superview])
            [yourImageView removeFromSuperview];
}
未央 2024-12-10 06:08:57

正确设置containerView的框架。您将其设置为不正确的frontImageView.bounds。

Set containerView's frame properly.You have set it to frontImageView.bounds that is not right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文