ios - objective-c : Resizing a UIImageView

标签 ios objective-c uiimageview

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

相关文章:

ios - iOS 6 中的 UIPickerView 选择行崩溃

ios - ABPeoplePickerNavigationController shouldContinueAfterSelectingPerson 返回搜索结果

ios - 应用内购买下载期间设备用尽了磁盘空间

ios - 如何在 swift 3 中为图像启用过滤器?

javascript - 如何监听后台变化(Parse Server)

ios - 使用 firebase 和 Objective C 不接收推送通知

objective-c - Uncrustify:单行方法名称并删除双星号之间的空格

ios - UIView::addSubView 遮挡了原本位于顶部的导航栏

ios - 如何在 UIImageView 中加载图像数组

ios - 如何制作透明的tableview?