gpt4 book ai didi

ios - objective-c : Resizing a UIImageView

转载 作者:行者123 更新时间:2023-11-29 01:51:56 24 4
gpt4 key购买 nike

我正在尝试调整 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com