Iphone 在UIImageView中访问已调整大小的UIImage的帧

Iphone 在UIImageView中访问已调整大小的UIImage的帧,iphone,ios,resize,uiimage,Iphone,Ios,Resize,Uiimage,我在UIImageView中设置了一个UIImage,并使用ContentModeAspectToFit。如何访问已调整大小的显示图像的边框?因为imageView.image.size.width提供了图像的原始宽度,而不是大小调整后的宽度 谢谢,UIImageView的属性帧将返回显示图像的帧 如果您想要更改框架,您应该将新的CGRect框架设置为UIImageView 例如: UIImageView *imgView; imgView.frame = CGRectMake(0, 0, ne

我在UIImageView中设置了一个UIImage,并使用ContentModeAspectToFit。如何访问已调整大小的显示图像的边框?因为imageView.image.size.width提供了图像的原始宽度,而不是大小调整后的宽度

谢谢,

UIImageView的属性帧将返回显示图像的帧

如果您想要更改框架,您应该将新的CGRect框架设置为UIImageView

例如:

UIImageView *imgView;
imgView.frame = CGRectMake(0, 0, newWidth, newHeight);
更新:

要计算新尺寸,可以使用以下代码:

UIImage *img;
UIImageView *iView;    
double widthRatio = img.size.width/iView.frame.size.width;
double heightRatio = img.size.height/iView.frame.size.height;
double ratio = widthRatio>heightRatio?widthRatio:heightRatio;
CGSize newImageSize;
newImageSize.width = img.size.width/ratio;
newImageSize.height = img.size.height/ratio;

我知道,我正在寻找新的宽度和新的高度的大小调整后的图像UIImageView.frame会给你大小调整后的图像这就是我刚才做的。这证实了我的想法!