1.设置View圆角 userhead.layer.masksToBounds = YES; userhead.layer.cornerRadius = 6.0; userhead.layer.borderWidth = 1.0; userhead.layer.borderColor = [[UIColor whiteColor] CGColor]; userhead可以是一个UIImageView,也可以是UIView 对了,记得在framework里面导入 #import <QuartzCore/QuartzCore.h>
2.xib下设置View圆角
这个很简单, 只需要重写 - (void)drawRect:(CGRect)rect 方法就行了
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
self.imgView.layer.cornerRadius = 20;
self.imgView.clipsToBounds = YES;
}