Skip to content

Instantly share code, notes, and snippets.

@cwalo
cwalo / AddShadowAndRoundedCorners.swift
Created January 10, 2018 19:44
Override layoutSubviews to add a new layer using a path with a roundedRect and cornerRadius
private var shadowLayer: CAShapeLayer!
private var cornerRadius: CGFloat = 25.0
private var fillColor: UIColor = .blue // the color applied to the shadowLayer, rather than the view's backgroundColor
override func layoutSubviews() {
super.layoutSubviews()
if shadowLayer == nil {
shadowLayer = CAShapeLayer()