You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1005 B

  1. //
  2. // ShadowView.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 28/08/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class ShadowView: UIView {
  10. private var shadowLayer: CAShapeLayer!
  11. private var cornerRadius: CGFloat = 5.0
  12. @IBInspectable
  13. private var shadowBackground: UIColor = .themeMainBackground
  14. override func layoutSubviews() {
  15. super.layoutSubviews()
  16. if shadowLayer == nil {
  17. shadowLayer = CAShapeLayer()
  18. } else {
  19. shadowLayer.removeFromSuperlayer()
  20. }
  21. shadowLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
  22. shadowLayer.fillColor = shadowBackground.cgColor
  23. shadowLayer.shadowColor = UIColor.black.cgColor
  24. shadowLayer.shadowPath = shadowLayer.path
  25. shadowLayer.shadowOffset = CGSize(width: 0.0, height: 0.5)
  26. shadowLayer.shadowOpacity = 0.5
  27. shadowLayer.shadowRadius = 1
  28. layer.insertSublayer(shadowLayer, at: 0)
  29. }
  30. }