How we created a floating menu for an iOS application

How much time do you spend tapping something on your smartphones? Is it something about an hour a day? We doubt that. According to the latest research, people use their phones an average of five hours a day.

As we spend so much time on our devices, we want them to work fast and effectively. No matter how many times we use our smartphones to connect to the Internet and check our email, we want it fast.

Radial menu layouts are the latest word in mobile apps technology. Being restricted to a single level makes them very efficient. One good example of using radial floating menus is social networks.

We created a floating menu that saves your time when accessing social networks as it directs you to your chats of profile immediately. Our menu is the analog to UITabBarContoller, and we named it EEMenuController. Our controller is equipped with the floating menu, which can be transformed from the bottom bar and moved to any screen location of our choice.

 

floating_menu_animation.gif

How we developed the component

EEMenuController class that inherits from NSObject serves as the singleton that ensures navigation between screens at any point of the project.   

Here is the step-by-step info how we created the controller:

  1. First, we needed to program the function similar to UITabBarController functional. For that, we created a bottom panel EEBottomPanelView that offers similar functions as UITabBar. Besides, we created EEContentVC for content navigation.
  2. Then, we implemented the transformation of the bottom bar into the floating one.
  3. Next, we set the margins position to prevent the floating menu from sticking to the center of the screen.
  4. Lastly, we created a separated pie chart menu.

How we developed a floating menu

A floating menu consists of two parts:

  • A floating button, which can be moved and converted from the bottom panel.
  • Pie menu, which expands into several sub-menus when clicked or tapped.

When creating a floating menu we have to keep two things in mind. First, the menu cannot overlap the content. Second, we cannot lose visibility of the menu items as it expands. Therefore, we set the margins of the menu within the limits of the customized space.

floating_area.jpg

 

Related: Key components of a successful mobile product

 

Issues we had to address

  1. A limited number of menu items. Pie menu can only display one to five tabs. With more tabs tapping becomes hindered. At this point, we faced two issues.
  2. A shape of menu items. We used this article to draw the shape, but adding spaces between the items became our problem. Since the items’ shape is drawn from the cones, every next size decrease brings the angle change. So, we lose the symmetry.

 

segment_example_wrong.png

We solved this problem by giving the same length value to the external and internal arcs instead of decreasing the item’s angle. In our case, it was 4 points.

segment_example_correct.png

  1. Clickability of the items. To restrict menu clickability to items only we overrode the method pointInside: withEvent:
    - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
     BOOL lReturn = NO;
     for (EEFloatingPaneTabButton *lTabButton in _tabButtonsArr) {
         if ([lTabButton pointInside:[self convertPoint:point toView:lTabButton] withEvent:event]) {
             lReturn = YES;
             break;
         }
    return lReturn;
    }
  2. Proper display of content. When the floating menu is active then the content might be displayed all over the screen. For that, each UIViewController has to implement the protocol EEMenuContentProtocol and arrange elements properly.
  3. Showing floating menu anchored to a view. The problem is that the user cannot hold the floating button forever. As soon as the user releases the button, it has to be located in the right position. To achieve it, we created an algorithm that calculates the final point of anchoring depending on the direction and speed of menu floating on the screen.  

How to use menu

Our team of iOS developers created a sample project, which you can download from GitHub. For your convenience in labeling the items, we created EEMenuTab class.

 

Related: Mobile trends in 2016: peering into the future

 

How to customize our component

  1. Select the margins of the fixed floating area.
    [EEMenuConroller.shareInstance setFloatingAreaInsets:UIEdgeInsetsMake(100.0f, 0.0f, 0.0f, 0.0f)];
  2. Select color patterns
    [EEMenuConroller.shareInstance setBottomPanelColor:[UIColor colorWithWhite:0.95f alpha:1.0f]];

    [EEMenuConroller.shareInstance setBottomPanelTintColor:[UIColor lightGrayColor]];

    [EEMenuConroller.shareInstance setBottomPanelActiveTintColor:[UIColor colorWithRed:147.0f/255.0f green:207.0f/255.0f blue:28.0f/255.0f alpha:1.0f]];


    [EEMenuConroller.shareInstance setFloatingPanelColor:[UIColor whiteColor]];

    [EEMenuConroller.shareInstance setFloatingPanelTintColor:[UIColor lightGrayColor]];

    [EEMenuConroller.shareInstance setFloatingPanelActiveTintColor:[UIColor colorWithRed:147.0f/255.0f green:207.0f/255.0f blue:28.0f/255.0f alpha:1.0f]];

 

To sum up, you do not have to worry about getting the floating menu anymore. Feel free to use this information to create and customize it. Also, you can get a free template here. It will save your time and grant you a trendy and effective menu.

Share via:
Recommended posts:
Smart Lock: Why Sloth Is A Driver of The IoT Progress
8/16/18

Smart Lock: Why Sloth Is A Driver of The IoT Progress

Top 7 IoT startups in 2019
3/28/19

Top 7 IoT startups in 2019

Microsoft Azure IoT Suite: Benefits and Features
1/2/19

Microsoft Azure IoT Suite: Benefits and Features

Interested in latest news in IT sphere?

Subscribe to start receiving notifications about new posts
17 Sep 2019

5 IoT Trends to Watch in 2020

4 Sep 2019

Why Node.js Is the Best Solution for Internet of Things

27 Aug 2019

How we created IoT system for managing solar energy usage

12 Aug 2019

Deploying CI server on Linux: Personal android test machine