All Products
Search
Document Center

Mobile Platform as a Service:Menu component

Last Updated:Mar 02, 2022

The floating layer menu provides a menu containing icons and an option list.

When using it, you need to change the APNavPopview and APNavItemView in the original AntUI frameWork to AUFloatMenu and AUNavItemView.

Sample images

  • Popover with red dots

    Popover with red dots
  • Popover with icons

    Popover with icons
  • Popover with texts only

    Popover with texts only

API description

  • AUFloatMenu.h

//
//  AUFloatMenu.h
//  AntUI
//

#import <UIKit/UIKit.h>
/* The notice of popview hiding. */
static NSString * const APExtUIPopViewDissmissedNotification = @"APExtUIPopViewDissmissedNotification";



@class AUNavItemView;
/*!
 @class       AUFloatMenu
 @abstract    UIView
 @ Discussion floatViewMenu The floating layer.
 */
@interface AUFloatMenu : UIView<UIGestureRecognizerDelegate>
@property(nonatomic, assign) CGFloat marginToRight;  // The right margin of a white popview, which is 10 by default.

/**
 * Create a floating menu view.
 *
 * @param position The position where the floating menu is displayed on the screen.
 * @param items The array of displayed content, which is generally an APNavItemView object.
 *
 * @return The floating menu view.
 */
+(AUFloatMenu *)showAtPostion:(CGPoint)position items:(NSArray<AUNavItemView *> *)items;

/**
 * Create a floating menu view.
 *
 * @param position The position where the floating menu is displayed on the screen.
 * @param orignY The y-coordinate value of the floating menu on the screen.
 * @param items The array of displayed content, which is generally an APNavItemView object.
 *
 * @return The floating menu view.
 */
+(AUFloatMenu *)showAtPostion:(CGPoint)position startOrignY:(CGFloat)orignY items:(NSArray<AUNavItemView *> *)items;

/**
 * The interface method for hiding a floating menu.
 */
-(void)dismiss;

/**
 * After the menu is open, RPC is executed to load dynamically delivered menu items. After RPC is completed, the update() method is called to remove the original view and add a new view.
 */
- (void)updateWithItems:(NSArray<AUNavItemView*> *)items;

@end
  • AUNavItemView.h

//
//  AUNavItemView.h
//  AntUI
//

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, AUCurrentTabType)  {
    AUCurrentTabTypeHome = 0,
    AUCurrentTabTypeKouBei,
    AUCurrentTabTypeFriend,
    AUCurrentTabTypeWealth
};
/*!
 @class                 AUNavItemView
 @abstract              UIView
 @ Discussion floatMenu The view of each column at the floating layer.
 */
@interface AUNavItemView : UIView
/**
 *  title
 */
@property(nonatomic,strong)NSString *itemTitle;

@property(nonatomic,strong,readonly)UIFont *titleFont;

/**
 * The normal state.
 */
@property(nonatomic,strong)UIImage *nomarlStateIconImage;

/*
 * IconFont Name: If iconFont needs to be set, the AUNavItemView.h but not AUFloatMenu.h API is invoked.
 */
@property(nonatomic,strong)NSString *nomarlStateIconFontName;

/**
 * If widgetId is set, badgeNumber does not need to be set.
 */
@property(nonatomic,strong)NSString *badgeNumber;

/**
 *  widgetId
 */
@property(nonatomic, copy) NSString *widgetId;

/**
 * The required prompt text for VoiceOver. The default value is the value of itemTitle. If itemTitle is not set, you need to manually set this attribute to support VoiceOver.
 */
@property(nonatomic,strong)NSString *voiceOverText;

@property(nonatomic,assign)BOOL isNavigationItem;

@property(nonatomic,assign,readonly)CGFloat touchEventMargin;

@property(nonatomic,assign)AUCurrentTabType currentTabType;

@property(nonatomic,assign,readonly)CGFloat marginBetweenIconTitle;

@property(nonatomic,assign,readonly)CGFloat marginBetweenLeftIcon;

@property(nonatomic,assign,readonly)CGFloat badgeViewWidth;

/**
 * This method needs to be rewritten for a sub-class, and then the clicking event is processed.
 */
- (void)onClicked;

/**
 Return the size of the icon view.

 @return size
 */
- (CGSize) iconViewSize;

@end

Sample code

  • Example of a popover with red dots:

//
//  APNavPopViewViewController.m
//  UIDemo
//

#import "APNavPopViewViewController.h"
#import "AUUtils.h"
#import "AUNavItemView.h"
#import "AUFloatMenu.h"
#import "AntUIShellObject.h"
#import "AUIconView.h"

@interface APNavPopViewViewController ()

@end

@implementation APNavPopViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(0xF5F5F9);

    self.navigationItem.title = @"Popover with red dots";
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    self.navigationItem.rightBarButtonItem = rightItem;
    [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)onClick:(id)sender
{
    NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];

    NSArray *items = @[@"Add Contacts",@"New Chat",@"Scan",@"Receive Money",@"Help"];
    int i = 0;
    for (NSString *typeName in items)  {
        AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(20, 0, 0, 40)];
        item.itemTitle = typeName;
        item.isNavigationItem = NO;
        // iconfont is supported.
   //     item.nomarlStateIconFontName = kICONFONT_USER_ADD;
        if (i == 0 ) {
            item.badgeNumber = @"1";
            UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 1) {
            item.badgeNumber = @"10";
            UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 2) {
            item.badgeNumber = @"100";
            UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 3) {
            item.badgeNumber = @"5";
            UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 4) {
            UIImage *image = [UIImage imageNamed:@"ap_help.png"];
            item.nomarlStateIconImage = image;
        }
        i++;

        [array addObject:item];
    }

    [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
}

- (void)onBarButtonClick:(id)sender
{
}


@end
  • Example of a popover with icons:

//
//  APNavPopViewViewController.m
//  UIDemo
//

#import "APNavPopViewNoneRedViewController.h"
#import "AUUtils.h"
#import "AUNavItemView.h"
#import "AUFloatMenu.h"
#import "AntUIShellObject.h"
#import "AUIconView.h"

@interface APNavPopViewNoneRedViewController ()

@end

@implementation APNavPopViewNoneRedViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(0xF5F5F9);

    self.navigationItem.title = @"Popover with icons";
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    self.navigationItem.rightBarButtonItem = rightItem;
    [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)onClick:(id)sender
{
    NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];

    NSArray *items = @[@"Add Contacts",@"New Chat",@"Scan",@"Receive Money",@"Help"];
    int i = 0;
    for (NSString *typeName in items)  {
        AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(20, 0, 0, 40)];
        item.itemTitle = typeName;
        item.isNavigationItem = NO;
        // iconfont is supported.
   //     item.nomarlStateIconFontName = kICONFONT_USER_ADD;
        if (i == 0 ) {
//            item.badgeNumber = @"1";
            UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 1) {
//            item.badgeNumber = @"10";
            UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 2) {
//            item.badgeNumber = @"100";
            UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 3) {
//            item.badgeNumber = @"5";
            UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
            item.nomarlStateIconImage = image;
        } else if(i == 4) {
            UIImage *image = [UIImage imageNamed:@"ap_help.png"];
            item.nomarlStateIconImage = image;
        }
        i++;

        [array addObject:item];
    }

    [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
}

- (void)onBarButtonClick:(id)sender
{
}


@end
  • Example of a popover with texts only:

//
//  APNavPopViewViewController.m
//  UIDemo
//

#import "APNavPopViewOnlyViewController.h"
#import "AUUtils.h"
#import "AUNavItemView.h"
#import "AUFloatMenu.h"
#import "AntUIShellObject.h"
#import "AUIconView.h"

@interface APNavPopViewOnlyViewController ()

@end

@implementation APNavPopViewOnlyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(0xF5F5F9);

    self.navigationItem.title = @"Popover with texts only";
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    self.navigationItem.rightBarButtonItem = rightItem;
    [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)onClick:(id)sender
{
    NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];

    NSArray *items = @[@"Add Contacts",@"New Chat",@"Scan",@"Receive Money",@"Help"];
    int i = 0;
    for (NSString *typeName in items)  {
        AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(0, 0, 0, 40)];
        item.itemTitle = typeName;
        item.isNavigationItem = NO;
        // iconfont is supported.
   //     item.nomarlStateIconFontName = kICONFONT_USER_ADD;
//        if (i == 0 ) {
////            item.badgeNumber = @"1";
//            UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
//            item.nomarlStateIconImage = image;
//        } else if(i == 1) {
////            item.badgeNumber = @"10";
//            UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
//            item.nomarlStateIconImage = image;
//        } else if(i == 2) {
////            item.badgeNumber = @"100";
//            UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
//            item.nomarlStateIconImage = image;
//        } else if(i == 3) {
////            item.badgeNumber = @"5";
//            UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
//            item.nomarlStateIconImage = image;
//        } else if(i == 4) {
//            UIImage *image = [UIImage imageNamed:@"ap_help.png"];
//            item.nomarlStateIconImage = image;
//        }
        i++;

        [array addObject:item];
    }

    [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
}

- (void)onBarButtonClick:(id)sender
{
}


@end