NavigationBarAppearance

open class NavigationBarAppearance : NSObject

导航栏样式配置

  • 根据style获取全局appearance对象

    Declaration

    Swift

    public static func appearance(for style: NavigationBarStyle) -> NavigationBarAppearance?
  • 设置style对应全局appearance对象

    Declaration

    Swift

    public static func setAppearance(_ appearance: NavigationBarAppearance?, for style: NavigationBarStyle)
  • 是否半透明(磨砂),需edgesForExtendedLayout为Top|All,默认false

    Declaration

    Swift

    open var isTranslucent: Bool
  • 前景色,包含标题和按钮,默认nil

    Declaration

    Swift

    open var foregroundColor: UIColor?
  • 标题属性,默认nil使用前景色

    Declaration

    Swift

    open var titleAttributes: [NSAttributedString.Key : Any]?
  • 按钮属性,默认nil。仅iOS15+生效,iOS14及以下请使用UIBarButtonItem

    Declaration

    Swift

    open var buttonAttributes: [NSAttributedString.Key : Any]?
  • 背景色,后设置生效,默认nil

    Declaration

    Swift

    open var backgroundColor: UIColor?
  • 背景图片,后设置生效,默认nil

    Declaration

    Swift

    open var backgroundImage: UIImage?
  • 背景透明,需edgesForExtendedLayout为Top|All,后设置生效,默认false

    Declaration

    Swift

    open var backgroundTransparent: Bool
  • 阴影颜色,后设置生效,默认nil

    Declaration

    Swift

    open var shadowColor: UIColor?
  • 阴影图片,后设置生效,默认nil

    Declaration

    Swift

    open var shadowImage: UIImage?
  • 返回按钮图片,自动配合VC导航栏样式生效,默认nil

    Declaration

    Swift

    open var backImage: UIImage?
  • 左侧返回按钮图片,自动配合VC导航栏样式生效,默认nil

    Declaration

    Swift

    open var leftBackImage: UIImage?
  • 自定义句柄,最后调用,可自定义样式,默认nil

    Declaration

    Swift

    open var appearanceBlock: ((UINavigationBar) -> Void)?