DropdownTitleView

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

  • Owner: GitHawkApp/DropdownTitleView
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

Main metrics

Overview
Name With OwnerGitHawkApp/DropdownTitleView
Primary LanguageSwift
Program languageRuby (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2018-10-21 18:39:50
Pushed At2020-02-01 21:39:50
Last Commit At2018-10-23 07:39:15
Release Count1
Last Release Name0.1.0 (Posted on )
First Release Name0.1.0 (Posted on )
用户参与
Stargazers Count254
Watchers Count4
Fork Count13
Commits Count9
Has Issues Enabled
Issues Count1
Issue Open Count0
Pull Requests Count0
Pull Requests Open Count1
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private