UIView 垂直翻转 [英] UIView flip vertically

查看:80
本文介绍了UIView 垂直翻转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能是一个愚蠢的问题,但我不得不问:如何垂直翻转 UIView?我不是要求做动画,只是翻转它.

I know it's probably a dummy question, but I have to ask: How to flip a UIView vertically? I'm not asking for doing a animation, but just flip it.

我可以通过以下方式垂直翻转 UILabel:

I can do vertical flip a UILabel by:

label1.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);

然后把它转回来:

label1.layer.transform = CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 0.0f);

但是当我对视图执行此操作时:

But when I'm doing it to a view:

self.view.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);

我认为它只旋转了一半......所以,有什么想法吗?

I think it only rotate half way... So, any ideas?

谢谢各位.

推荐答案

我意识到这是一个老问题,但无论如何我会留在这里.以下将仅使用图层的 y 比例垂直翻转视图,因此这是我的偏好:

I realize this is an old question, but I'll leave this here anyway. The following would flip the view vertically using just the y-scale of the layer, so it would be my preference:

self.view.layer.transform = CGAffineTransform(scaleX: 1, y: -1)

这篇关于UIView 垂直翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆