iOS只给矩形两个边加圆角
- (void)updataTopCornerRadius { CGRect clipRect = CGRectMake(0, 0, self.headPhotoIv.width, self.headPhotoIv.width); UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:clipRect byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = clipRect; maskLayer.path = maskPath.CGPath; self.headPhotoIv.layer.mask = maskLayer; }