IOS应用开发16——UIViewContentMode各类型参数样式效果

来源:互联网 发布:上海浦东机场有没有mac 编辑:程序博客网 时间:2024/05/19 02:43

UIView有一个属性:contentMode,用来表示如何显示内容,取值参数为:

typedef NS_ENUM(NSInteger, UIViewContentMode) {    UIViewContentModeScaleToFill,    UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent    UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped.    UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)    UIViewContentModeCenter,              // contents remain same size. positioned adjusted.    UIViewContentModeTop,    UIViewContentModeBottom,    UIViewContentModeLeft,    UIViewContentModeRight,    UIViewContentModeTopLeft,    UIViewContentModeTopRight,    UIViewContentModeBottomLeft,    UIViewContentModeBottomRight,};
具体的显示效果怎么样呢,有图有真相,我们以UIImageView为示例来说明歌参数的效果,基本代码如下:

_photoView = [UIImageView new];_photoView.frame = CGRectMake(10, kMarginTop+5,                              kScreenWidth - 10*2, 240);_photoView.backgroundColor = [UIColor greenColor];NSString *str = @"http://i5.hexunimg.cn/2014-09-18/168589835.jpg";_photoView setImageURLStr:str placeholder:nil]_photoView.contentMode = UIViewContentModeScaleToFill;[self.view addSubview:_photoView];

附效果图,使用参数见标题




0 0
原创粉丝点击