CariocaMenu

public class CariocaMenu: NSObject, CariocaGestureManagerDelegate, UITableViewDelegate, UITableViewDataSource

🇧🇷 Carioca Menu 🇧🇷

  • The menu’s content controller

    Declaration

    Swift

    let controller: CariocaController
  • The view in which the menu will be displayed

    Declaration

    Swift

    let hostView: UIView
  • The edges of the menu. Supported : .left, .right

    Declaration

    Swift

    let edges: [UIRectEdge]
  • The container view. Created programatically, it takes the same dimensions as the host view

    Declaration

    Swift

    let container: CariocaMenuContainerView
  • Gestures manager

    Declaration

    Swift

    let gestureManager: CariocaGestureManager
  • The selected index of the menu. Default: 0

    Declaration

    Swift

    internal var selectedIndex: Int
  • The indicatorView

    Declaration

    Swift

    let indicator: CariocaIndicatorView
  • The delegate receiving menu’s events

    Declaration

    Swift

    weak var delegate: CariocaDelegate?
  • Initialises 🇧🇷 Carioca Menu 🇧🇷

    Declaration

    Swift

    public init(controller: CariocaController,
    hostView: UIView,
    edges: [UIRectEdge],
    delegate: CariocaDelegate,
    selectedIndex: Int = 0,
    indicator: CariocaIndicator)

    Parameters

    controller

    The menu’s dataSource

    hostView

    The view in which the menu will be displayed

    edges

    The supported edges

    delegate

    The menu’s event delegate

    selectedIndex

    The menu’s default selected index

    indicator

    The custom indicator view

  • Adds the menu’s container view in the host view

    Declaration

    Swift

    public func addInHostView()
  • Bring the indicator on top of all views

    Declaration

    Swift

    public func bringToFront()
  • Called from the hostview, if a rotation has been detected. Moves the indicator at 50% of the hostView.

    Declaration

    Swift

    public func hostViewDidRotate()
  • Tap gesture event received. Forwards parameters to GestureManager, to simulate a Pan gesture.

    Declaration

    Swift

    @objc func tappedIndicatorView(_ gesture: UITapGestureRecognizer)

    Parameters

    gesture

    UITapGestureRecognizer

  • Menu will open. Forwards call to openFromEdge

    Declaration

    Swift

    internal func willOpenFromEdge(edge: UIRectEdge)

    Parameters

    edge

    The opening edge of the menu

  • Show the menu

    Declaration

    Swift

    internal func showMenu()
  • Hide the menu

    Declaration

    Swift

    internal func hideMenu(_ duration: Double? = nil)

    Parameters

    duration

    The fading duration, optional. If not set, the menu is immediately hidden.

  • The selection index was updated, while user panning in the view

    Declaration

    Swift

    internal func didUpdateSelectionIndex(_ index: Int, selectionFeedback: Bool)

    Parameters

    index

    The updated selection index

    selectionFeedback

    Should we make a selection feedback?

  • Haptick feedback, if supported. Min iOS 10.0.

    Declaration

    Swift

    internal func makeSelectionFeedback()
  • The user did select a menu item

    Declaration

    Swift

    internal func didSelectItem(at index: Int)

    Parameters

    index

    The selected index

  • Number of menu items

    Declaration

    Swift

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
  • Cell for row. Forwarded to the controller, with the extra edge parameter.

    Declaration

    Swift

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  • Number of sections. Cannot be updated for now, as the menu’s tableView only supports 1 section

    Declaration

    Swift

    public func numberOfSections(in tableView: UITableView) -> Int
  • UITableView selection delegate, forwarded to CariocaDelegate

    Declaration

    Swift

    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
  • Takes the specified heightForRow passed in the initialiser

    Declaration

    Swift

    public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
  • Default footer view (to hide extra separators)

    Declaration

    Swift

    public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
  • Generates an Equal constraint

    Declaration

    Swift

    class func equalConstraint(_ item: AnyObject,
                               toItem: AnyObject,
                               attribute: NSLayoutAttribute,
                               constant: CGFloat = 0.0) -> NSLayoutConstraint

    Parameters

    item

    The reference

    toItem

    The linked view

    attribute

    The NSLayoutAttribute

    constant

    The constant value. Default: 0

    Return Value

    NSLayoutConstraint: The prepared constraint

  • Logs a string in the console

    Declaration

    Swift

    public class func log(_ log: String)

    Parameters

    log

    The log message