0

To generate rounded button with top-left & bottom left radius I use the following code:

    var maskPath = UIBezierPath(roundedRect: button.bounds,
        byRoundingCorners: .BottomLeft | .TopLeft,
        cornerRadii: CGSizeMake(15.0, 15.0))
    var shapeLayer:CAShapeLayer = CAShapeLayer()
    shapeLayer.frame = self.view.bounds
    shapeLayer.path  = maskPath.CGPath;
    button.layer.mask = shapeLayer;
    button.layer.borderWidth = self.borderWidth
    button.layer.borderColor = GenerateShape.UIColorFromHex(self.borderStrokeColor, alpha: (self.alphaValue-0.3)).CGColor
    button.backgroundColor = GenerateShape.UIColorFromHex(self.whiteColor, alpha: (self.alphaValue-0.3))

But I get the following output: enter image description here

So why top-left & bottom-left corner is invisible?? What should I do to make them visible?? Thanks.

Linkon Sid
  • 521
  • 1
  • 5
  • 16

1 Answers1

2

You are using your bezier path as a mask. But you are not also drawing your bezier path; you are drawing the rectangular border of the button itself. Thus, your mask is masking out the corners of the rectangular border.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • so what should I do to draw it properly. please suggest with a piece of code. thanks – Linkon Sid Oct 04 '15 at 19:16
  • I don't know exactly what you want to do. And I'm not going to write your code for you. You asked: "why top-left & bottom-left corner is invisible". I explained it to you. If you look at your own code and think about it, you will see that what I'm saying is true and logical. Then think about what you want and write your code so that it does that instead. For example, perhaps instead of drawing the button border, you should try drawing the bezier path. – matt Oct 04 '15 at 22:20