Development platform: iOS
Language: Swift
UI framework: UIKit
Compatibility: iOS 11 or greater
TomatoHorizontalBottomMenu Framework lets you create a horizontal, scrollable menu at the bottom of the screen. Each sub-menu corresponds to a specific view controller. Since the entire menu content is scrollable, you can add as many sub-menus as you want to the horizontal menu. The following is a list of features.
- Add five, six or as many sub-menus as you want to the horizontal menu.
- Use an image to characterize each sub-menu.
- Use two label colors, normal and highlight. The latter applies to the view controller that is currently selected.
- Have options of having or not having a cave-in area at the top.
- Adjust the cave-in width.
- Have options of having or not having a vertical line between sub-menus.
- In order to use this framework, download the sample project. You will find the folder titled TomatoFramework. Locate the Xcode file inside. And put this Xcode file in your Xcode project. Select your target and make sure you have TomatoHorizontalMenuFramework.framework under General > Framworks, Libraries, and Embeded Content as shown below.
-
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 BaseViewController. Import TomatoHorizontalMenuFramework to the view controller.
-
In the base view controller, set the class to TomatoHorizontalViewController. Create a function to set up the menu. Let us call this function setup(index: Int). Also create an override function named menuTapped.
-
In the setup function, create an array of menu models with TomatoHorizontalMenuModel. This struct takes three properties: name (String), imageName (String), menuIndex (Int). The name property is the name of a tappable sub-menu. And each of them corresponds to a specific view controller through the menuTapped function. The imageName* property refers to the name of the image used to characterize each sub-menu. And the index property determines the order of appearance. It also tells the app which view controller it should access.
-
Call tomatoSetup(index: index) in the setup(index: Int) function of the base view controller.
-
Use the menuTapped function to read sender view's tag to direct the app to a specific view controller. The following is an example.
- In each view controller to which the app is directed to, change the class to BaseViewController. In its viewDidLoad method, call setup(index: number), where 'number' is an Int type value of a menu model from No. 4.