// // ShadowView.swift // GME Remit // // Created by InKwon James Kim on 28/08/2019. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import UIKit class ShadowView: UIView { private var shadowLayer: CAShapeLayer! private var cornerRadius: CGFloat = 5.0 private var shadowBackground: UIColor = .themeMainBackground override func layoutSubviews() { super.layoutSubviews() if shadowLayer == nil { shadowLayer = CAShapeLayer() } else { shadowLayer.removeFromSuperlayer() } shadowLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowLayer.fillColor = shadowBackground.cgColor shadowLayer.shadowColor = UIColor.black.cgColor shadowLayer.shadowPath = shadowLayer.path shadowLayer.shadowOffset = CGSize(width: 0.0, height: 0.5) shadowLayer.shadowOpacity = 0.5 shadowLayer.shadowRadius = 1 layer.insertSublayer(shadowLayer, at: 0) } }