ベジェ曲線を使用する
typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
UIRectCornerTopLeft = 1 << 0、
UIRectCornerTopRight = 1 << 1、
UIRectCornerBottomLeft = 1 << 2、
UIRectCornerBottomRight = 1 << 3、
UIRectCornerAllCorners = ~0UL
};
//16色
#define RGB16Color(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 緑:((float)((rgbValue & 0xFF00) >> 8))/255.0 青:(( float)(rgbValue & 0xFF))/255.0 alpha:1.0]
UIButton *chooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
chooseButton.frame = CGRectMake(10, 15, 86, 24);
[self.view addSubview:chooseButton];
UIBezierPath *maskPath_two = [UIBezierPath bezierPathWithRoundedRect:chooseButton.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight CornerRadii:CGSizeMake(5,5)];
//レイヤーを作成
CAShapeLayer *maskLayer_two = [[CAShapeLayer alloc] init];
MaskLayer_two.frame = selectButton.bounds;
//割り当て
マスクレイヤー_ツー.パス = マスクパス_ツー.CGPath;
選択ボタン.レイヤー.マスク = マスクレイヤー_2;
上記を踏まえて枠線を設定します
//境界線を設定する
CAShapeLayer *borderLayer = [CAShapeLayer レイヤー];
borderLayer.frame = selectButton.bounds;
borderLayer.path = マスクパス_two.CGPath;
borderLayer.lineWidth = 1;
borderLayer.fillColor = [UIColor ClearColor].CGColor;
borderLayer.ストロークカラー = RGB16Color(0x30C26D).CGColor;
[chooseButton.layer addSublayer:borderLayer];