我有一个 UIImageView,它的框架在加载图像之前设置,对于图像来说总是太大,所以当我尝试圆角时,例如,没有任何反应.
I have a UIImageView whose frame, set before the image is loaded, is always too large for the image, so when I try to round the corners, for example, nothing happens.
如何调整框架的大小,使其与底层图像的大小相同,同时确保 UIImageView 的中心点不会改变?
How can I resize the frame so it's the same size as the underlying image, while ensuring that the center point of the UIImageView does not change?
如果改变 UIView 的边界,中心不会改变.
If you change the bounds of a UIView the center will not change.
CGRect bounds;
bounds.origin = CGPointZero;
bounds.size = newImage.size;
imageView.bounds = bounds;
imageView.image = newImage;
这篇关于如何调整 UIImageView 的大小以适应底层图像而不移动它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!