xcode UIView 垂直翻转
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9627006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIView flip vertically
提问by user966422
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.
我知道这可能是一个愚蠢的问题,但我不得不问:如何UIView
垂直翻转?我不是要求做动画,而是翻转它。
I can do vertical flip a UILabel
by:
我可以UILabel
通过以下方式进行垂直翻转:
label1.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);
label1.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);
and turn it back by:
并通过以下方式将其转回:
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?
我认为它只能旋转一半......所以,有什么想法吗?
Thanks guys.
谢谢你们。
回答by Mathew
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:
我意识到这是一个老问题,但无论如何我都会把它留在这里。以下将仅使用图层的 y 比例垂直翻转视图,因此这将是我的偏好:
self.view.layer.transform = CGAffineTransform(scaleX: 1, y: -1)