베지어 곡선 사용
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 알파:1.0]
UIButton * chooseButton = [UIButton 버튼WithType:UIButtonTypeCustom];
chooseButton.frame = CGRectMake(10, 15, 86, 24);
[self.view addSubview:chooseButton];
UIBezierPath *maskPath_two = [UIBezierPath 베지어PathWithRoundedRect: chooseButton.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottom오른쪽 모서리Radii:CGSizeMake(5,5)];
//레이어 생성
CAShapeLayer *maskLayer_two = [[CAShapeLayer 할당] 초기화];
MaskLayer_two.frame = chooseButton.bounds;
//과제
마스크레이어_투.패스 = 마스크패스_투.CGPath;
chooseButton.layer.mask = MaskLayer_two;
위 내용을 바탕으로 테두리를 설정합니다.
//테두리 설정
CAShapeLayer *borderLayer = [CAShapeLayer 레이어];
borderLayer.frame = chooseButton.bounds;
borderLayer.path=maskPath_two.CGPath;
borderLayer.lineWidth = 1;
borderLayer.fillColor = [UIColorclearColor].CGColor;
borderLayer.StrokeColor = RGB16Color(0x30C26D).CGColor;
[chooseButton.layer addSublayer:borderLayer];