[英]Creating a UIImageVIew with the exact size of an image
如何从图像中检测尺寸,然后使用该尺寸创建UIImageView,完美贴合图像内部?
Just create the UIImageView like this: 只需像这样创建UIImageView:
UIImageView *aImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.png"]];
So the ImageView has the size of the image. 因此ImageView具有图像的大小。 From the Documentation of UIImageView: 从UIImageView的文档:
This method adjusts the frame of the receiver to match the size of the specified image. 此方法调整接收器的帧以匹配指定图像的大小。 It also disables user interactions for the image view by default. 默认情况下,它还会禁用图像视图的用户交互。
I hope my answer helps you. 我希望我的回答可以帮到你。 :-D :-D
Sandro 桑德罗
Here no need to set the frame size when we use the image in imageView 在imageView中使用图像时,无需设置帧大小
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
ImageView will automatically takes the size of image. ImageView将自动获取图像的大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.