UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_view2.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _view2.bounds;
maskLayer.path = maskPath.CGPath;
_view2.layer.mask = maskLayer;
以上方法来自http://webfrogs.me/2013/05/22/ios-view-assign-corner-radius/