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;