UIView flip vertically

和自甴很熟 提交于 2021-02-06 15:10:52

问题


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.

I can do vertical flip a UILabel by:

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.


回答1:


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)


来源:https://stackoverflow.com/questions/9627006/uiview-flip-vertically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!