`
zhengjj_2009
  • 浏览: 148577 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

iOS的UIViewContentMode取值和效果分析

阅读更多

    CGRect frame = CGRectMake(10, 70, 300, 350);

    imageView = [[UIImageViewalloc] initWithFrame:frame];

    imageView.backgroundColor = [UIColorredColor];

    imageView.image = [UIImageimageNamed:@"80"];

    imageView.contentMode = UIViewContentModeScaleToFill;

    //默认填充值, 上下左右必定全部填充

    

    //imageView.contentMode = UIViewContentModeScaleAspectFit;

    //contents scaled to fit with fixed aspect. remainder is transparent

    //在保持图片长宽比(aspect)的前提下, 缩放图片(scale),使图片在容器内(UIImageView)都显示出来(fit)

    

    //imageView.contentMode = UIViewContentModeScaleAspectFill;

    // contents scaled to fill with fixed aspect. some portion of content may be clipped.

    // 在保持纵横比(aspect)的前提下, 缩放图片(scale), 使图片充满容器(fill)

    

    //imageView.contentMode = UIViewContentModeRedraw;

    //redraw on bounds change (calls -setNeedsDisplay)

    //效果等同于默认值的效果UIViewContentModeScaleToFill

    

    imageView.contentMode = UIViewContentModeCenter;

    // contents remain same size. positioned adjusted.

    // 图片保持尺寸不变,只是所在的坐标位置进行了调整,

    // 其他的几个Top Bottom Left Right及其组合可以从字面理解就行

 

    [self.viewaddSubview:imageView];

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics