BFPaperButton icon indicating copy to clipboard operation
BFPaperButton copied to clipboard

FEATURE REQUEST : Button Radius

Open Adrian-Sweeney opened this issue 8 years ago • 1 comments

I would like to put two buttons side by side and have the left side of button one be curved and the right side of button two be curved

Also if I could have the ability to specify if the radius us specified on specific corners

Button.RadiusTopLeft = <CGFloat> Button.RadiusTopRight = <CGFloat> Button.RadiusBottomLeft = <CGFloat> Button.RadiusBottomRight = <CGFloat>

Also would it be possible to specify that the button is transparent with a border

Button.BorderWidth = <NSInteger> Button.BorderColor = <UIColor>

We are having to use a couple of images in a view and would like to replace them with your button

Adrian-Sweeney avatar Oct 03 '17 10:10 Adrian-Sweeney

Hi @Adrian-Sweeney

Unfortunately this control doesn't support arbitrary Bezier paths. The reason being that for the layer to 'clip' to a path, we have to mask it. If we mask it, we lose the underlying shadow :/ If we use .layer.cornerRadius (which this control currently does) then we don't have to mask anything, but we affect all 4 corners.

However, if I can find some time I will try and work around this for the next release.

As for the border color and border width, you can add these yourself very easily until the feature makes it into the release version by adding some code to BFPaperButton.h/m:

Add to BFPaperButton.h:

@property (nonatomic) IBInspectable UIColor *borderColor;
@property (nonatomic) IBInspectable CGFloat borderWidth;

Add to BFPaperButton.m:

// In -(void)layoutSubviews, towards the bottom of this function, right before [self setEnabled:self.enabled];
self.layer.borderColor = self.borderColor.CGColor;
self.backgroundColorFadeLayer.borderColor = self.borderColor.CGColor;
self.layer.borderWidth = self.borderWidth;
self.backgroundColorFadeLayer.borderWidth = self.borderWidth;

// Right after #pragma mark - Setters, add these 2 functions:
- (void)setBorderColor:(UIColor *)borderColor {
    _borderColor = borderColor;
    self.layer.borderColor = borderColor.CGColor;
    self.backgroundColorFadeLayer.borderColor = borderColor.CGColor;
}

- (void)setBorderWidth:(CGFloat)borderWidth {
    _borderWidth = borderWidth;
    self.layer.borderWidth = borderWidth;
    self.backgroundColorFadeLayer.borderWidth = borderWidth;
}

bfeher avatar Oct 04 '17 08:10 bfeher