通常我們要Button 或是 View 要圓角的時候我們都直接
[view.layer setCorerRadius:8.0f]
但這個方法是讓四邊都是圓角
若是只想要某一個角是圓角要怎麼做呢
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(8.0, 8.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
UIRectCornerTopLeft 左上圓角
UIRectCornerTopRight 右上圓角
UIRectCornerBottomLeft 左下圓角
UIRectCornerBottomRight 右下圓角