1

Can someone please help me with this question in iOS Swift. I have an UI view with drop shadow effect. I need corner radius for 3 corners except for one corner. Any help is appreciated.

Thanks, Dharani

  • Welcome to StackOverflow. Please take the [tour](http://stackoverflow.com/tour) have a look around, and read through the [HELP center](http://stackoverflow.com/help), then read [How to Ask Question](http://stackoverflow.com/help/how-to-ask), [What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask) and provide a [MCVE : Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). If people around can easily read and understand what you mean, or what the problem is, they'll be more likely willing to help :) – Dwhitz Feb 26 '18 at 08:25
  • Stack Overflow has so many answers for every question. you gotta search in a right way. – Ganesh Kumar Feb 26 '18 at 10:27
  • https://stackoverflow.com/questions/10167266/how-to-set-cornerradius-for-only-top-left-and-top-right-corner-of-a-uiview – Ganesh Kumar Feb 26 '18 at 10:27

1 Answers1

0

You can use extension on UIView:

Here is a sample I created on Playgrounds:

let view = UIView()

extension UIView {
    func roundCorners(_ corners:UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        self.layer.mask = mask
    }
}
// customize where you want your roundCorners on your UIView
view.roundCorners([.topLeft, .topRight, .bottomRight], radius: 10)
Vjardel
  • 1,065
  • 1
  • 13
  • 28
  • https://stackoverflow.com/questions/10167266/how-to-set-cornerradius-for-only-top-left-and-top-right-corner-of-a-uiview – Ganesh Kumar Feb 26 '18 at 10:25