GitHawkApp / Dropdowntitleview
Licence: mit
A UINavigationItem.titleView compatible UIControl with a title, subtitle, and dropdown.
Stars: ✭ 256
Programming Languages
swift
15916 projects
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
}
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
andtitleColor
-UIFont
andUIColor
of the top title label -
subtitleFont
andsubtitleColor
-UIFont
andUIColor
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
- Leavenil
to remove the subtitle and vertically center the title -
chevronEnabled
- Set tofalse
to remove the chevron -
accessibilityLabel
andaccessibilityHint
- Set Accessibility features on the control
Acknowledgements
- Created with ❤️ by Ryan Nystrom
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].