我正在尝试调整 UIImageView 的大小。我尝试的是像这样直接编辑 ImageView 的框架
verticalBar.frame = CGRectMake(verticalBar.frame.origin.x, verticalBar.frame.origin.y, verticalBar.frame.size.width, verticalBar.frame.size.height);
然而,即使我根本没有更改任何值,图像也会大大扭曲。我的意思是我有一个 45 度角的旋转矩形(我使用 CGAfflineTransformMakeRotation),但是当我尝试编辑它的框架时,如上图所示,矩形变成了 5 倍宽。不确定是什么问题。任何帮助都会很棒!
最佳答案
来自 UIView frame
的文档:
However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.
因此要么保留变换并更新 ImageView 的中心
和边界
,要么重置变换以设置框架
。
关于ios - objective-c : Resizing a UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31305121/