且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 iOS8 下使用 CGAffineTransform 旋转时 UIView 不调整大小

更新时间:2023-02-02 14:28:31

这更像是一种解决方法而不是修复方法,因此它可能无法帮助处于类似情况的每个人.我的问题是,在应用转换后,外部固定"视图再次调整大小.

This is more of a work around than a fix so it may not help everybody in similar situations. My problem was that the outer "pinned" view was being resized again after the transform was applied.

我的解决方案是将固定视图上的约束更改为垂直居中,水平居中,并且宽度和高度等于一个常数.

My solution was to change the constraints on the pinned view to be center vertically, center horizontally, and width and height equal a constant.

然后,在 viewDidLoad 中,我将固定视图框架的高度和宽度设置为主屏幕的高度.这使得视图呈方形,所以我不在乎它是否得到额外的旋转.

Then, in viewDidLoad, I set the height and width of the pinned view's frame to be the height of the main screen. This makes the view square so I don't care if it gets an extra rotate.