【问题标题】:How to make UIImage shown as the size of the UIView如何使 UIImage 显示为 UIView 的大小
【发布时间】:2014-10-10 10:44:39
【问题描述】:
UIImage *image = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
NSLog(@"%f %f %f %f ", (image.size.width/9), (image.size.height/16), (568/image.size.height), (round((568/image.size.height) * image.size.width)));
if((image.size.width/9)<(image.size.height/16)){
    imageLoad.frame = CGRectMake(0, 0, 320, round((320/image.size.height) * image.size.height));
}
else if((image.size.width/9)>(image.size.height/16)){
    imageLoad.frame = CGRectMake(0, 0, round((568/image.size.height) * image.size.width), 568);
}
else{
    imageLoad.frame = CGRectMake(0, 0, round((568/image.size.height) * image.size.width), 568);
}
NSLog(@"%f %f", imageLoad.frame.size.width, imageLoad.frame.size.height);
imageLoad.hidden = NO;
imageLoad.image = image;

我使用CGRectMake 更改了UIImageView *imageLoad 的大小,我认为UIImage *image 将显示为UIImageView *imageLoad 的大小。但是,它没有用。我该怎么办?

【问题讨论】:

    标签: objective-c xcode uiimage cgrectmake


    【解决方案1】:
    // this means your image is fit in to your view size
    imageLoad.contentMode = UIViewContentModeScaleAspectFill
    

    【讨论】:

      【解决方案2】:
      imageLoad.contentMode = UIViewContentModeScaleAspectFill
      

      【讨论】:

      猜你喜欢
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      相关资源
      最近更新 更多