通常,当我们向 UIImageView 添加一个大图像(该 ImageView 是一个 subview )时,它会占用整个窗口大小,因为 UIImageView 需要一些时间来调整 ImageView 的大小。我想获得最小调整大小时间(afterDelay 时间)。
self.capturedImgV.image =image;
[self performSelector:@selector(resizeImageView) withObject:nil afterDelay:1];
最佳答案
以下文章讨论了缩放图像的不同方法,并介绍了缩放不同类型图像的时间安排。
http://nshipster.com/image-resizing/
重要的信息是方法之间的相对时间。 UIKit 似乎表现不错,所以最好不要担心并接受速度,因为它是给定的,除了自己在后台渲染较小的版本然后将 View 设置为您的缩小版本之外,您可能对此几乎无能为力一次完成版本。
一个想法是你可以提供一个 UIImageView
的子类并实现它的 drawRect:
方法来做计时,但它看起来像因为 UIImageView
优化为直接绘制到屏幕上,这在绘制图像时不会被调用。
The UIImageView class is optimized to draw its images to the display. UIImageView does not call the drawRect: method of its subclasses. If your subclass needs to include custom drawing code, you should subclass the UIView class instead.
关于ios - 如何等到 uiimageview 在 objective-c 中调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28671800/