设置图片圆角 或者圆形
1.//用画图的方式设置圆角
mImageView.image=[UIImage imageNamed:@"bg1.png"];
mImageView.frame=CGRectMake(center.x-radius, center.y-radius, 2*radius, 2*radius);
mImageView.layer.cornerRadius=radius;//设置圆角半径
mImageView.layer.masksToBounds=YES;
[mImageView.layer setBorderWidth:1];//设置边框宽度
[mImageView.layer setBorderColor:[UIColor whiteColor].CGColor];//设置边框颜色
[self addSubview:mImageView];
2.
必须在uiimageView加载之后设置
//设置图片为圆角的
CALayer *imageLayer = [cell.userPicView layer]; //获取ImageView的层
[imageLayer setMasksToBounds:YES];
[imageLayer setCornerRadius:6.0];
uiview圆角
viewT.layer.cornerRadius = 10;//设置那个圆角的有多圆
iewT.layer.borderWidth = 10;//设置边框的宽度,当然可以不要
viewT.layer.borderColor = [[UIColor redColor] CGColor];//设置边框的颜色
viewT.layer.masksToBounds = YES;
3.圆形图片
UIImageView *headImage = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"portrait_bg_80"]];
headImage.frame = CGRectMake(imageTop.frame.origin.x+10, imageTop.frame.origin.y+10, 35, 35);
//将radius设置为长度或者宽度的一半就可以实现圆形的图片
headImage.layer.cornerRadius = 35/2.0;
headImage.layer.masksToBounds = YES;
[headImage.layer setBorderWidth:1];
[headImage.layersetBorderColor:[UIColorwhiteColor].CGColor];