/TomatoHorizontalMenu

Horizontally-scrollable top menu framework

Primary LanguageSwiftGNU General Public License v3.0GPL-3.0

TomatoHorizontalMenu Framework

Development and compatibility

Development platform: iOS
Language: Swift
UI framework: UIKit
Compatibility: iOS 13 or greater

Description

TomatoHorizontalMenu lets you create a horizontally-scrollable menu right below the navigation controller for switching from one view controller to another. The following is a list of features.

  1. List a number of tappable sub-menus, each of which corresponds to a specific view controller.
  2. The default height of the horizontal menu is 60 points and can be flexible.
  3. The default space between the tappable labels is 30 points can be flexible.
  4. You have options of letting the framework set auto layout such that the horizontal menu will automatically adjust when the device is lotated.
  5. You can customize the highlighted label text color and non-highlighted label text color.

Installation

  1. In order to use this framework, download the sample project. You will find the folder titled TomatoHorizontalMenu Framework. Locate the Xcode file inside. And put this Xcode file in your Xcode project. Select your target and make sure you have TomatoHorizontalMenu under General > Framworks, Libraries, and Embeded Content as shown below.

  1. Create a sub-class of UIViewController. Name it BasicViewController, BaseViewController, RootViewController or whatever you want such that all child view controllers can be based on. For now, let us call this base view controller BasicViewController. Import TomatoHorizontalMenu to the view controller.

  2. In the base view controller, set the class to TomatoHorizontalBaseController. Create a function to set up the menu. Let us call this function setup. Also create an override function named switchViewController.

  3. In the setup function, create an array of menu models with TomatoHorizontalMenuModel. This struct takes two properties: name (String) and index (Int). The name property is the name of a sub-menu that appears on the horizontal menu. Each sub-menu is supposed to point to a specific view controller. The index property determines the order of appearance.

  4. Use the switchViewController function to read sender view's tag to direct the app to a specific view controller. The following is an example.

  1. In each view controller to which the app is directed to, change the class to BasicViewController. In its viewDidLoad method, set an integer (tag) to viewIndex. Also, call the setup function.

Variables

  • menuHeight: It's the height of the horizontal menu. The default height is 60 points.
  • labelTextColor: It's the text color over the sub-menu.
  • labelHighlightTextColor: It's the text color over the sub-menu for the currently-selected view controller.
  • labelHeight: It's the height of the text label over the sub-menu.
  • labelFontSize: It's the font size of the text label over the sub-menu.
  • menuHighlightColor: It's the color of the sub-menu for the currently-selected view controller.
  • menuHighlightHeight: It's the height of the horizontal hightlight line.
  • spaceBetween: It's the space between two sub-menus.
  • boxBorderColor: It's the border color around the horizontal scroll view.
  • borderWidth: It's the weight of the border around the horizontal scroll view.
  • showHorizontalScroller: It's a boolean value as to whether or not to show the horizontal scroller.
  • scrollBackColor: It's the background color of the horizontal scroll view.
  • hasLayoutConstraints: Set it to true if you want the framework to set autolayout constraints.
  • autoScroll: If you set it to true, the selected sub-menu will appear to the left after the user switches view controllers.