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];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值