JXSegmentedCollectionView.swift 836 B

12345678910111213141516171819202122232425262728293031323334353637
  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]() {
  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. if let backgroundView = backgroundView {
  27. sendSubviewToBack(backgroundView)
  28. }
  29. }
  30. }
  31. }