DropdownTitleView

A UINavigationItem.titleView compatible UIControl with a title, subtitle, and dropdown.

  • 所有者: GitHawkApp/DropdownTitleView
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

DropdownTitleView

A simple and configurable "dropdown" view built for UINavigationItem.titleView.

Installation

Just add DropdownTitleView to your Podfile and pod install. Done!

pod 'DropdownTitleView'

Usage

Create an instance of DropdownTitleView, configure it, and set it as a UINavigationItem's titleView:

func viewDidLoad() {
  super.viewDidLoad()
  let titleView = DropdownTitleView()
  titleView.configure(title: "Hello world!", subtitle: "Is this thing on?")
  navigationItem.titleView = titleView
}

Example

Add touch handling like you would any other UIControl:

func viewDidLoad() {
  super.viewDidLoad()
  // setup and set titleView
  titleView.addTarget(
    self, 
    action: #selector(onTitle), 
    for: .touchUpInside
  )
}

@objc func onTitle() {
  print("do something")
}

Configuration

DropdownTitleView has several appearance options:

  • titleFont and titleColor - UIFont and UIColor of the top title label
  • subtitleFont and subtitleColor - UIFont and UIColor of the bottom subtitle label
  • chevronTintColor - UIColor tint of the chevron image

All of these values are configurable via UIAppearance as well!

DropdownTitleView.appearance().chevronTintColor = .blue
DropdownTitleView.appearance().titleColor = .black
DropdownTitleView.appearance().subtitleColor = .lightGray
DropdownTitleView.appearance().titleFont = .systemFontOfSize(18)
DropdownTitleView.appearance().subtitleFont = .systemFontOfSize(13)

You can also control the features of the view with params in configure(...) function:

  • subtitle - Leave nil to remove the subtitle and vertically center the title
  • chevronEnabled - Set to false to remove the chevron
  • accessibilityLabel and accessibilityHint - Set Accessibility features on the control

Acknowledgements

主要指標

概覽
名稱與所有者GitHawkApp/DropdownTitleView
主編程語言Swift
編程語言Ruby (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2018-10-21 18:39:50
推送於2020-02-01 21:39:50
最后一次提交2018-10-23 07:39:15
發布數1
最新版本名稱0.1.0 (發布於 )
第一版名稱0.1.0 (發布於 )
用户参与
星數254
關注者數4
派生數13
提交數9
已啟用問題?
問題數1
打開的問題數0
拉請求數0
打開的拉請求數1
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?