Latest 0.1.0
Homepage https://github.com/AhmedFathi680/AFSubtitleNavigationItem
License MIT
Platforms ios 9.0
Authors

Version
License
Platform

Alt text

Create custom title and subtitle labels in your native navigation item.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Requires iOS 9.0 or later.

Installation

AFSubtitleNavigationItem is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'AFSubtitleNavigationItem'

Usage

Start by importing AFSubtitleNavigationItem in your AppDelegate

import AFSubtitleNavigationItem

In your viewController’s viewDidLoad method write the below:

navigationItem.isSubtitleEnabled = true
navigationItem.titleLabel?.text = "Title"
navigationItem.subtitleLabel?.text = "Subtitle"

Warning Make sure this view controller actually have a navigationController, i.e. it’s not directly presented without being in a navigation controller stack.
You can also your custom navigation item to your presented view controller and use AFSubtitleNavigationItem properties directly.

Customiziations

Actually there is not limit here but only your imagination. titleLabel and subtitleLabel are both just mere UILabels.

navigationItem.titleLabel?.textColor = UIColor.blue
navigationItem.titleLabel?.attributedText = NSAttributedString(string: "Attributed Title")
navigationItem.titleLabel?.textAlignment = .left

Appearance allover the app

You can customize all your navigationItems allover the application easily by using the below code:

Customizing titles:

UINavigationItem.appearance.titleTextColor = .darkGray
UINavigationItem.appearance.titleTextFont = UIFont.systemFont(ofSize: 17, weight: .medium)
UINavigationItem.appearance.titleTextShadowColor = UIColor.black.withAlphaComponent(0.05)
UINavigationItem.appearance.titleTextShadowOffset = CGSize(width: 0.5, height: 0.5)

Customizing Subtitles:

UINavigationItem.appearance.subtitleTextColor = .darkGray
UINavigationItem.appearance.subtitleTextFont = UIFont.systemFont(ofSize: 13, weight: .thin)
UINavigationItem.appearance.subtitleTextShadowColor = UIColor.black.withAlphaComponent(0.05)
UINavigationItem.appearance.subtitleTextShadowOffset = CGSize(width: 1, height: 1)

Author

Ahmed Fathi, [email protected]

License

This code is distributed under the terms and conditions of the MIT license.

Latest podspec

{
    "name": "AFSubtitleNavigationItem",
    "version": "0.1.0",
    "summary": "Create custom title and subtitle labels in your native navigation item.",
    "description": "Extending the navtive navigationItem capabilities to instantly add custom title and subtitle labels.nThe labels are fully customizable and works very well with the bar button items.",
    "homepage": "https://github.com/AhmedFathi680/AFSubtitleNavigationItem",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ahmed Fathi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ahmedfathi680/AFSubtitleNavigationItem.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "swift_version": "4.0",
    "source_files": "AFSubtitleNavigationItem/Classes/**/*"
}

Pin It on Pinterest

Share This