Skip to content

NotchToolbar

Ahmed Fathi Bekhit edited this page Nov 9, 2017 · 4 revisions

Class

NotchToolbar

NotchToolbar is the class that handles the initialization and configuration of the NotchBar, initializing the protocols, and triggering protocols when an events are changed.


Topics

Initializing and Configuring

var delegate: NotchToolbarDelegate?

The delegate object that handles device orientation changes and toolbar icon selection.

var notch: NotchBar

The variable that initializes and draws a NotchBar.

var scrollMode: notchScroll

A notchScroll variable that allows you to configure the scrolling direction of the toolbar. Default is auto.

var onlyFor10: Bool

A boolean that allows you to configure whether you want to show the NotchBar only on iPhone X or older iPhone devices too. Default is false.

var tools: UICollectionView?

The UICollectionView where the tool icons are added.

var toolIconSize: CGSize

A variable that allows you to configure the size of the icon cells. Default is CGSize(width: 60, height: 60).

var toolIconsInsets: UIEdgeInsets

A variable that allows you to configure the UICollectionView edge insets. Default is UIEdgeInsets(top:5, left:35, bottom:5, right:35).

var toolList: [Any?]

An array that accepts Strings, UIImages or an array of both types.
String types allows you to add full size emojis.
UIImage types allows you to add image icons.
[String, UIImage] an array of both types allows you to add an image icon with a title.

var toolsTitleFont: UIFont

A variable that allows you to change the font of String type icons.

var toolsTitleColor: UIColor

A variable that allows you to change the color of String type icons.

var iconWithNameFont: UIFont

A variable that allows you to change the font of the title in an array of [String, UIImage] type icons.

var iconWithNameColor: UIColor

A variable that allows you to change the color of the title in an array of [String, UIImage] type icons.

func prepare(in vc:UIViewController)

Prepares the NotchToolbar with default configurations in a UIViewController. To customize your NotchToolbar, make sure to configure it with the new settings before calling prepare(in vc:UIViewController).

Displaying and Resizing the notch

func showOrHide()

A method that allows you to show and hide the NotchBar. This method automatically detects if the NotchBar is visible or not.

To get the current NotchBar visibility, use notch.isVisible.

func autoResize()

A method that automatically resize the NotchBar. You must call this method in deviceDidRotate delegate in order to have the NotchBar working properly in different device orientations.