Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (22 sloc) 662 Bytes
//
// UINavigationItemExtensions.swift
// SwifterSwift
//
// Created by Omar Albeik on 9/28/16.
// Copyright © 2016 SwifterSwift
//
#if canImport(UIKit) && !os(watchOS)
import UIKit
// MARK: - Methods
public extension UINavigationItem {
/// SwifterSwift: Replace title label with an image in navigation item.
///
/// - Parameter image: UIImage to replace title with.
func replaceTitle(with image: UIImage) {
let logoImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 30))
logoImageView.contentMode = .scaleAspectFit
logoImageView.image = image
titleView = logoImageView
}
}
#endif
You can’t perform that action at this time.