JXSegmentedCollectionView.swift 728 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // JXSegmentedCollectionView.swift
  3. // JXSegmentedView
  4. //
  5. // Created by jiaxin on 2018/12/26.
  6. // Copyright © 2018 jiaxin. All rights reserved.
  7. //
  8. import UIKit
  9. open class JXSegmentedCollectionView: UICollectionView {
  10. open var indicators = [JXSegmentedIndicatorProtocol & UIView]() {
  11. willSet {
  12. for indicator in indicators {
  13. indicator.removeFromSuperview()
  14. }
  15. }
  16. didSet {
  17. for indicator in indicators {
  18. addSubview(indicator)
  19. }
  20. }
  21. }
  22. open override func layoutSubviews() {
  23. super.layoutSubviews()
  24. for indicator in indicators {
  25. sendSubviewToBack(indicator)
  26. }
  27. }
  28. }