kruttinangopal
kruttinangopal

Reputation: 21

How to get rounded corners only on bottom of the blurview with clear color on iOS?

I'm placing the blurview in a UITableViewCell. So the cell's background color is set to clear color. But I want specific corners to be rounded as well.

I came across this solution for getting rounded corners.

  1. Create a CAShapeLayer.
  2. Create a UIBezierPath with specific corners and cornerRadii.
  3. Apply it to the CAShapeLayer and add as a mask of the target view's layer.

But this works only when the view has a background color. I just want the specific corners rounded with clear color.

Thanks in advance.

Upvotes: 0

Views: 301

Answers (1)

gurmandeep
gurmandeep

Reputation: 1247

Try this

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.viewOutlet.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path  = maskPath.CGPath;
self.viewOutlet.layer.mask = maskLayer;  

enter image description here

Upvotes: 1

Related Questions