O2CustomViewProtocol.swift 664 B

123456789101112131415161718192021222324252627
  1. //
  2. // O2CustomViewProtocol.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2021/12/30.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. protocol O2CustomViewProtocol {
  10. var contentView: UIView! { get }
  11. func commonInit(for customViewName: String)
  12. }
  13. extension O2CustomViewProtocol where Self: UIView {
  14. func commonInit(for customViewName: String) {
  15. Bundle.main.loadNibNamed(customViewName, owner: self, options: nil)
  16. addSubview(contentView)
  17. contentView.backgroundColor = .clear
  18. contentView.frame = bounds
  19. contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  20. }
  21. }