NavigationBarDesginable.swift 863 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // Created by Jake Lin on 12/10/15.
  3. // Copyright © 2015 IBAnimatable. All rights reserved.
  4. //
  5. import UIKit
  6. public protocol NavigationBarDesignable: class {
  7. /**
  8. Specify whether is solid color only, if `true` will remove hairline from navigation bar
  9. */
  10. var solidColor: Bool { get set }
  11. }
  12. public extension NavigationBarDesignable where Self: UINavigationBar {
  13. func configureNavigationBar() {
  14. if solidColor {
  15. let emptyImage = UIImage()
  16. setBackgroundImage(emptyImage, for: .any, barMetrics: .default)
  17. shadowImage = emptyImage
  18. // Need to manually untick translucent in Interface Builder,
  19. // otherwise, it will have constrait issue in IB although it is correct in run time.
  20. // translucent = false
  21. } else {
  22. setBackgroundImage(nil, for: .any, barMetrics: .default)
  23. shadowImage = nil
  24. }
  25. }
  26. }