美文网首页
IOS UIImageView的加载图片方式

IOS UIImageView的加载图片方式

作者: shanshan950224 | 来源:发表于2015-12-11 10:51 被阅读426次

  • 图片的加载方式一(代码添加)

UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"图片"]];
    /*
     UIViewContentModeScaleToFill,
// contents scaled to fit with fixed aspect. remainder is transparent
     UIViewContentModeScaleAspectFit,      
     UIViewContentModeScaleAspectFill,
     */
    imgView.contentMode = UIViewContentModeScaleAspectFit;

  • 图片的加载方式二(xib添加图片)


  • 图片的填充方式

  • Scale To Fill 按照大小进行填充(会改变形状、比例)----看不到背景

  • Aspect Fit 原图大小(不会变形),等比例缩放----可以看到背景

  • Aspect Fill 按照大小比例进行填充,不会改变比例大小填充(有可能图片不齐全,宽高比不变)----看不到背景

    • fill 填充

    • Aspect 比例、等级、规模

    • Scale 大小

    • Fit 适应

相关文章

网友评论

      本文标题:IOS UIImageView的加载图片方式

      本文链接:https://www.haomeiwen.com/subject/mneyhttx.html