FlaneurNavigationBar
final public class FlaneurNavigationBar: UIView
A visual control aiming to reproduce the visual aspect of a UINavigationBar
, with a custom height size,
but without the functional part requiring a UINavigationController
.
Overview
A FlaneurNavigationBar
is a bar, typically displayed at the top of the window, containing buttons that
can be easily customized with blocks. The primary components are a left button, a title, and an optional
array of right buttons. You must use a flaneur navigation bar as a standalone object. It has no compatibility
whatsoever with a navigation controller object.
Behaviors
When a left action is configured, then the whole navigation bar actions it. It does not interfere with the right buttons.
Using a FlaneurNavigationBar
If you’re using a storyboard to instanciate your views, you should try to use a height of 66 pt. After placing the view, you can configure its content programmatically:
@IBOutlet weak var navigationBar: FlaneurNavigationBar!
let leftAction = FlaneurNavigationBarAction(image: ...) { _ in
...
}
self.navigationBar.configure(title: ...,
leftAction: myLeftAction)
Customizing the appearance of the bar via UIAppearance
You can customize the appearance of a FlaneurNavigationBar
via UIAppearance
so that it has a consistent
appearance in your app with unique lines of code.
For instance, the following code makes the title of the bar use the Futura font everywhere in your app:
UILabel.appearance(whenContainedInInstancesOf: [FlaneurNavigationBar.self]).font = UIFont(name: "Futura-Medium", size: 16.0)
Demo
The FlaneurOpen demo app includes a demo for FlaneurNavigationBar
. Cf. FlaneurNavigationBarDemoViewController
.
-
Undocumented
Declaration
Swift
public let bottomBorder = UIView()
-
Read-only getter for
UIButton
instances of the right part of the bar.Declaration
Swift
public private(set) var rightButtons: [UIButton] = []
-
Initializes and returns a newly allocated navigation bar object with the specified frame rectangle.
Declaration
Swift
public override init(frame: CGRect)
Parameters
frame
The frame rectangle for the view, measured in points.
-
Returns an object initialized from data in a given unarchiver.
Declaration
Swift
public required init?(coder: NSCoder)
Parameters
coder
An unarchiver object.
-
Configures the bar with content.
This method should only be called once per instance.
Declaration
Swift
public func configure(title: String, leftAction: FlaneurNavigationBarAction? = nil, rightActions: [FlaneurNavigationBarAction]? = nil)
Parameters
title
The string to set as the title displayed in the center of the navigation bar.
leftAction
An optional custom action. The associated control will be displayed on the left edge of the navigation bar.
rightActions
An optional array of custom actions. The associated controls will be displayed on the right edge of the navigation bar. The first item will be the closest from the right edge (ie controls will be displayed right-to-left)
-
Sets the title.
Declaration
Swift
public func setTitle(_ title: String)
Parameters
title
The string to set as the title displayed in the center of the navigation bar.
-
Sets the optional left action for the bar.
Declaration
Swift
public func setLeftAction(_ leftAction: FlaneurNavigationBarAction?)
Parameters
leftAction
the action.
-
Sets the optional right actions for the bar.
Declaration
Swift
public func setRightActions(_ rightActions: [FlaneurNavigationBarAction]?)
Parameters
rightActions
the actions.