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)