gpt4 book ai didi

ios - 使用 AsyncImageView 将图像加载到 ImageView 宽度

转载 作者:行者123 更新时间:2023-11-29 01:46:00 25 4
gpt4 key购买 nike

我使用 AsyncImageView 从 url 加载图像。但是图像没有加载到 ImageView 宽度。下面是我的代码。

{
AsyncImageView *asyImage;
asyImage = [[AsyncImageView alloc] initWithFrame:frame];
[asyImage loadImageFromURL:[NSURL URLWithString:url]];
[propertyImage addSubview:asyImage];
propertyImage.contentMode = UIViewContentModeScaleAspectFit;
}

最佳答案

 NSString * urlString = @"http://img-paragon.sandicor.com/ParagonImages/Property/Q1/SANDICOR/150016147/0/0/0/729a48630a22f4436d3e45e671bb3548/1/e2d30ecd1633ebc3b6b1f6acbcc77331/150016147.JPG";
NSData *dataCoverImg = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage *imgLocation = [UIImage imageWithData:dataCoverImg];
self.image = [imgLocation resizedImage:self.propertyImage.frame.size interpolationQuality:kCGInterpolationMedium]; // Can we resize image using UIImage+Resize equel to imageview size

self.urlForTesting=[NSURL URLWithString:urlString];
CGRect frame = self.propertyImage.bounds; AsyncImageView *asyImage;
asyImage=[[AsyncImageView alloc] initWithFrame:frame];
asyImage.imageURL =self.urlForTesting;


asyImage.layer.borderWidth = 2.0f;
asyImage.contentMode = UIViewContentModeScaleToFill;
asyImage.layer.masksToBounds=YES;
[self.propertyImage addSubview:asyImage];

self.mySecondImageView.image = self.image; // set directly to asyncimage view with aspect mode AspectFill
self.myThirdImageView.image = self.image; //Set to normal Image view with aspect Mode ScaleToFill
// Do any additional setup after loading the view, typically from a nib.

在此代码中,我为您使用了三个 ImageView 示例,所有这些示例均根据 ImageView 大小获取完整图像

ImageView width management

关于ios - 使用 AsyncImageView 将图像加载到 ImageView 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31921785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com