ios - 如何等到 uiimageview 在 objective-c 中调整大小

标签 ios objective-c uiimageview

通常,当我们向 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/

相关文章:

iphone - 如何在导航栏中添加图像

ios - DBAccess:是否支持长长值?

ios - 在 sprite 上启用触摸(spritekit)

objective-c - ios中的字节数组

ios - 如何设置状态栏的文本颜色(白色和黑色除外)

ios - 从 UIImageView 派生的动态创建的控件缺少函数

ios - 为什么必须先初始化NSObject的.class-property才能对其进行初始化

ios - 我的应用程序内存问题警告,但应用程序不会消耗大量内存

ios - 如何使 UIButton 的一些文字变粗

ios - NSURLConnection 完成错误 - 代码 -1002 修复不起作用