iOS中UIView半边圆角设置

- (UIButton *)addButton {
    if (!_addButton) {
        self.addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _addButton.frame = CGRectMake(maxX(self.contentTextFiled), minY(self.contentTextFiled), BUTTONWIDTH*KScDefineWidth, BUTTONWIDTH*KScDefineWidth);
        //TODO:uiview 单边圆角或者单边框
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_addButton.bounds byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight) cornerRadii:CGSizeMake(5,5)];//圆角大小
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = _addButton.bounds;
        maskLayer.path = maskPath.CGPath;
        _addButton.layer.mask = maskLayer;
        
        [_addButton setBackgroundImage:[UIImage imageNamed:@"img_add_black"] forState:UIControlStateNormal];
        [_addButton addTarget:self action:@selector(addNumAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _addButton;
}

你可能感兴趣的:(iOS,Xcode,Object-c)