IOS APP圆形图片的实现

时间:2014-05-05 12:06:59   收藏:0   阅读:448
bubuko.com,布布扣
 1     //设置圆形cornerRadius,是宽或高的一半
 2 
 3     _imageView.layer.masksToBounds = YES;
 4 
 5     
 6 
 7     CGFloat w = _imageView.frame.size.width / 2;
 8 
 9     _imageView.layer.cornerRadius = w;
10 
11     
12 
13     //设置边框宽度及颜色
14 
15     [_imageView.layersetBorderWidth:2];
16 
17     [_imageView.layersetBorderColor:[[UIColorwhiteColor]CGColor]];
18 
19     
20 
21     //圆角设置(cornerRadius = 125,我用的图片是250*250,250的一半:125)
22 
23     _imageView.layer.cornerRadius = 125;
24 
25     _imageView.layer.masksToBounds = YES;
26 
27     
28 
29     //自动适应,保持图片宽高比
30 
31     _imageView.contentMode = UIViewContentModeScaleAspectFit;
bubuko.com,布布扣

 

IOS APP圆形图片的实现,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!