在不同大小的UIView中显示UIImageViews

时间:2014-07-23 05:46:23

标签: ios xcode uiview uiimageview

我正在以编程方式显示UIImageViews。它适用于第一个UIView,但是当我尝试在较小的view上显示它时,它不会调整大小。 你能帮助我吗。提前致谢

顺便说一句,我有一个名为UIView的{​​{1}}自定义类。我将这个类用于两个courtView

UIView

1 个答案:

答案 0 :(得分:0)

试试这段代码

UIImage *myImage = [UIImage imageNamed :@"myImage.extension"]; 
//if ur images are static, if your images are from an array then loop it out write the below inside the loop, make sure myImageView is a class,static component.
CGFloat height = myImage.size.height;
CGFloat width = myImage.size.width;

myImageView.frame = CGRectMake (myImageView.frame.origin.x,myImageView.frame.origin.y,height,width);
myImageView.image = myImage;

希望这有帮助