我正在处理图像,我有很多图像,并且我正在从服务器实时下载它们,在AsyncImageView
课程真的很快之前,但知道我正在使用自定义课程,UIImage
而不是UIImageView
.
问题:有什么好的方法可以转换UIImageView
成UIImage
?
提前致谢!
我正在处理图像,我有很多图像,并且我正在从服务器实时下载它们,在AsyncImageView
课程真的很快之前,但知道我正在使用自定义课程,UIImage
而不是UIImageView
.
问题:有什么好的方法可以转换UIImageView
成UIImage
?
提前致谢!
你不需要在 UIImage 中显示 UIImageView。也许你想在另一个 UIImageView 中显示一个 UIImageView,或者你想访问 UIImageView 的图像属性,你可以用 imageView.image 来做:
UIImage *imageFromImageView = myImageView.image
或者如果它是另一个图像视图选项中的图像视图:
[myOuterImageView addSubiew:myInnerImageView];
你没有UIImage
和UIImageView
完全正确的联系:你没有在它们之间转换,因为一个是实际图像的表示,另一个是显示图像的视图。
UIImageView 对象持有对 UIImage 对象的引用,允许该图像显示在屏幕上。查看UIImageView 文档,您将看到该类具有一个属性image
(UIImageView 将显示的图像),并且通过该属性您可以访问 UIImageView 中包含的 UIImage。
UIImage
是图像数据的抽象,它不显示任何内容。
UIImageView
是UIView
为显示UIImage
屏幕上表示的图像而优化的子类。
要获取UIImage
使用的UIImageView
,请使用 image 属性。
UIImageView *theUIImageYouGot = some assignment made already;
CusstomImage *theUIImageSubclassYouWantToDisplay = [theUIImageYouGot image];