1

Here today we will ask about some tricky to drop shadow to view with corner radius , what if I just want to create a view with top/bottom rounded corners and drop shadow? How can I do it in Swift?

Any help would be greatly appreciated.

Paresh Mangukiya
  • 37,512
  • 17
  • 201
  • 182
  • You can follow this post, hope that you can find your answer, https://stackoverflow.com/questions/25591389/uiview-with-shadow-rounded-corners-and-custom-drawrect – Chuong Tran Oct 31 '18 at 03:52

1 Answers1

1

You can do this without too much code:

let circleView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
circleView.backgroundColor = .darkGray
circleView.layer.cornerRadius = 50
circleView.layer.shadowColor = UIColor.green.cgColor
circleView.layer.shadowRadius = 10
circleView.layer.shadowOpacity = 1

Result:

circleWithShadow

AdamPro13
  • 7,002
  • 2
  • 28
  • 27