IHGuetsView.swift 1021 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // IHGuetsView.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/1/20.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHGuetsView: UIView {
  10. @IBOutlet weak var imageView: UIImageView!
  11. @IBOutlet weak var box: UIView!
  12. override func awakeFromNib() {
  13. super.awakeFromNib()
  14. }
  15. func createUI() {
  16. let width : CGFloat = 325
  17. let height : CGFloat = 350
  18. let r : CGFloat = (width * 0.5 * width * 0.5 + 35 * 35 ) / (2 * 35)
  19. let path0 = UIBezierPath(rect: CGRect(x: 0, y: 0, width: width, height: height - 35))
  20. path0.addArc(withCenter: CGPoint(x: width * 0.5, y: height - r), radius: r, startAngle: 1 / 4 * .pi, endAngle: 3 / 4 * .pi, clockwise: true)
  21. let masklayer = CAShapeLayer()
  22. masklayer.frame = self.imageView.bounds
  23. masklayer.path = path0.cgPath
  24. self.imageView.layer.mask = masklayer
  25. box.allRoundShadow()
  26. }
  27. }