RoundedCorners+ImageView.swift 674 B

12345678910111213141516171819202122232425262728
  1. //
  2. // RoundedCorners+ImageView.swift
  3. // LMS
  4. //
  5. // Created by Suraj Kumar Mandal on 03/10/23.
  6. //
  7. import Foundation
  8. import UIKit
  9. class RoundedTopCornersImageView: UIImageView {
  10. override class var layerClass: AnyClass {
  11. return CAShapeLayer.self
  12. }
  13. override func layoutSubviews() {
  14. super.layoutSubviews()
  15. let maskLayer = CAShapeLayer()
  16. maskLayer.path = UIBezierPath(
  17. roundedRect: bounds,
  18. byRoundingCorners: [.topLeft, .topRight],
  19. cornerRadii: CGSize(width: 10.0, height: 10.0) // Adjust the corner radius as needed
  20. ).cgPath
  21. layer.mask = maskLayer
  22. }
  23. }