全部产品
云市场

菜单组件

更新时间:2019-09-26 18:38:06

需要把原来的 APExtUI frameWork 中的(APNavPopview、APNavItemView)修改 为 AUFloatMenu 和 AUNavItemView,BEEBarPopMenu 也需要替换。

效果图

  • 带红点浮层

  • 带图标浮层

  • 纯文字浮层

接口说明

  • AUFloatMenu.h
  1. //
  2. // AUFloatMenu.h
  3. // AntUI
  4. //
  5. #import <UIKit/UIKit.h>
  6. /**popview 消失的通知*/
  7. static NSString * const APExtUIPopViewDissmissedNotification = @"APExtUIPopViewDissmissedNotification";
  8. @class AUNavItemView;
  9. /*!
  10. @class AUFloatMenu
  11. @abstract UIView
  12. @discussion floatViewMenu 浮层
  13. */
  14. @interface AUFloatMenu : UIView<UIGestureRecognizerDelegate>
  15. @property(nonatomic, assign) CGFloat marginToRight; //白色 popview 距离屏幕右侧的距离,不设置时默认为 10
  16. /**
  17. * 创建浮动菜单视图
  18. *
  19. * @param position 浮动菜单在屏幕上展示的位置
  20. * @param items 展示的内容数组,一般为 APNavItemView 对象
  21. *
  22. * @return 浮动菜单视图
  23. */
  24. +(AUFloatMenu *)showAtPostion:(CGPoint)position items:(NSArray<AUNavItemView *> *)items;
  25. /**
  26. * 创建浮动菜单视图
  27. *
  28. * @param position 浮动菜单在屏幕上展示的位置
  29. * @param orignY 浮动菜单在屏幕上y坐标值
  30. * @param items 展示的内容数组,一般为 APNavItemView 对象
  31. *
  32. * @return 浮动菜单视图
  33. */
  34. +(AUFloatMenu *)showAtPostion:(CGPoint)position startOrignY:(CGFloat)orignY items:(NSArray<AUNavItemView *> *)items;
  35. /**
  36. * 浮动菜单消失接口方法
  37. */
  38. -(void)dismiss;
  39. /**
  40. * 菜单点开后发 RPC 加载动态下发菜单项,RPC 完成后调 update,完成旧 view 移出,添加新 view 的过程
  41. */
  42. - (void)updateWithItems:(NSArray<AUNavItemView*> *)items;
  43. @end
  • AUNavItemView.h
  1. //
  2. // AUNavItemView.h
  3. // AntUI
  4. //
  5. #import <UIKit/UIKit.h>
  6. typedef NS_ENUM(NSInteger, AUCurrentTabType) {
  7. AUCurrentTabTypeHome = 0,
  8. AUCurrentTabTypeKouBei,
  9. AUCurrentTabTypeFriend,
  10. AUCurrentTabTypeWealth
  11. };
  12. /*!
  13. @class AUNavItemView
  14. @abstract UIView
  15. @discussion floatMenu 浮层中每栏的 view
  16. */
  17. @interface AUNavItemView : UIView
  18. /**
  19. * title
  20. */
  21. @property(nonatomic,strong)NSString *itemTitle;
  22. @property(nonatomic,strong,readonly)UIFont *titleFont;
  23. /**
  24. * 正常状态
  25. */
  26. @property(nonatomic,strong)UIImage *nomarlStateIconImage;
  27. /*
  28. * iconFont Name 如果是 iconFont 的话,则调用这个接口,不用调上面的接口
  29. */
  30. @property(nonatomic,strong)NSString *nomarlStateIconFontName;
  31. /**
  32. * 如果设置了 widgetId,就不需要设置 badgeNumber
  33. */
  34. @property(nonatomic,strong)NSString *badgeNumber;
  35. /**
  36. * widgetId
  37. */
  38. @property(nonatomic, copy) NSString *widgetId;
  39. /**
  40. *VoiceOver 需要的提示的文案,默认是 itemTitle,如果没有设置 itemTitle,需要手动设置此属性来支持 VoiceOver
  41. */
  42. @property(nonatomic,strong)NSString *voiceOverText;
  43. @property(nonatomic,assign)BOOL isNavigationItem;
  44. @property(nonatomic,assign,readonly)CGFloat touchEventMargin;
  45. @property(nonatomic,assign)AUCurrentTabType currentTabType;
  46. @property(nonatomic,assign,readonly)CGFloat marginBetweenIconTitle;
  47. @property(nonatomic,assign,readonly)CGFloat marginBetweenLeftIcon;
  48. @property(nonatomic,assign,readonly)CGFloat badgeViewWidth;
  49. /**
  50. * 子类需重写此方法,然后处理点击的事件
  51. */
  52. - (void)onClicked;
  53. /**
  54. 返回Iconview的size
  55. @return size
  56. */
  57. - (CGSize) iconViewSize;
  58. @end

代码示例

  • 带红点示例:
  1. //
  2. // APNavPopViewViewController.m
  3. // UIDemo
  4. //
  5. #import "APNavPopViewViewController.h"
  6. #import "AUUtils.h"
  7. #import "AUNavItemView.h"
  8. #import "AUFloatMenu.h"
  9. #import "AntUIShellObject.h"
  10. #import "AUIconView.h"
  11. @interface APNavPopViewViewController ()
  12. @end
  13. @implementation APNavPopViewViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor = RGB(0xF5F5F9);
  17. self.navigationItem.title = @"带红点浮层";
  18. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
  19. self.navigationItem.rightBarButtonItem = rightItem;
  20. [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (void)onClick:(id)sender
  27. {
  28. NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];
  29. NSArray *items = @[@"添加朋友",@"发起群聊",@"扫一扫",@"收钱",@"帮助"];
  30. int i = 0;
  31. for (NSString *typeName in items) {
  32. AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(20, 0, 0, 40)];
  33. item.itemTitle = typeName;
  34. item.isNavigationItem = NO;
  35. //支持iconfont
  36. // item.nomarlStateIconFontName = kICONFONT_USER_ADD;
  37. if (i == 0 ) {
  38. item.badgeNumber = @"1";
  39. UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
  40. item.nomarlStateIconImage = image;
  41. } else if(i == 1) {
  42. item.badgeNumber = @"10";
  43. UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
  44. item.nomarlStateIconImage = image;
  45. } else if(i == 2) {
  46. item.badgeNumber = @"100";
  47. UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
  48. item.nomarlStateIconImage = image;
  49. } else if(i == 3) {
  50. item.badgeNumber = @"5";
  51. UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
  52. item.nomarlStateIconImage = image;
  53. } else if(i == 4) {
  54. UIImage *image = [UIImage imageNamed:@"ap_help.png"];
  55. item.nomarlStateIconImage = image;
  56. }
  57. i++;
  58. [array addObject:item];
  59. }
  60. [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
  61. }
  62. - (void)onBarButtonClick:(id)sender
  63. {
  64. }
  65. @end
  • 带图标浮层示例:
  1. //
  2. // APNavPopViewViewController.m
  3. // UIDemo
  4. //
  5. #import "APNavPopViewNoneRedViewController.h"
  6. #import "AUUtils.h"
  7. #import "AUNavItemView.h"
  8. #import "AUFloatMenu.h"
  9. #import "AntUIShellObject.h"
  10. #import "AUIconView.h"
  11. @interface APNavPopViewNoneRedViewController ()
  12. @end
  13. @implementation APNavPopViewNoneRedViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor = RGB(0xF5F5F9);
  17. self.navigationItem.title = @"带图标浮层";
  18. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
  19. self.navigationItem.rightBarButtonItem = rightItem;
  20. [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (void)onClick:(id)sender
  27. {
  28. NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];
  29. NSArray *items = @[@"添加朋友",@"发起群聊",@"扫一扫",@"收钱",@"帮助"];
  30. int i = 0;
  31. for (NSString *typeName in items) {
  32. AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(20, 0, 0, 40)];
  33. item.itemTitle = typeName;
  34. item.isNavigationItem = NO;
  35. //支持iconfont
  36. // item.nomarlStateIconFontName = kICONFONT_USER_ADD;
  37. if (i == 0 ) {
  38. // item.badgeNumber = @"1";
  39. UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
  40. item.nomarlStateIconImage = image;
  41. } else if(i == 1) {
  42. // item.badgeNumber = @"10";
  43. UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
  44. item.nomarlStateIconImage = image;
  45. } else if(i == 2) {
  46. // item.badgeNumber = @"100";
  47. UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
  48. item.nomarlStateIconImage = image;
  49. } else if(i == 3) {
  50. // item.badgeNumber = @"5";
  51. UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
  52. item.nomarlStateIconImage = image;
  53. } else if(i == 4) {
  54. UIImage *image = [UIImage imageNamed:@"ap_help.png"];
  55. item.nomarlStateIconImage = image;
  56. }
  57. i++;
  58. [array addObject:item];
  59. }
  60. [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
  61. }
  62. - (void)onBarButtonClick:(id)sender
  63. {
  64. }
  65. @end
  • 纯文字浮层示例:
  1. //
  2. // APNavPopViewViewController.m
  3. // UIDemo
  4. //
  5. #import "APNavPopViewOnlyViewController.h"
  6. #import "AUUtils.h"
  7. #import "AUNavItemView.h"
  8. #import "AUFloatMenu.h"
  9. #import "AntUIShellObject.h"
  10. #import "AUIconView.h"
  11. @interface APNavPopViewOnlyViewController ()
  12. @end
  13. @implementation APNavPopViewOnlyViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor = RGB(0xF5F5F9);
  17. self.navigationItem.title = @"纯文字浮层";
  18. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"APCommonUI_ForDemo.bundle/more.png"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
  19. self.navigationItem.rightBarButtonItem = rightItem;
  20. [[AURegisterManager shareInstance] registerAUObject:[[AntUIShellObject alloc] init]];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (void)onClick:(id)sender
  27. {
  28. NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];
  29. NSArray *items = @[@"添加朋友",@"发起群聊",@"扫一扫",@"收钱",@"帮助"];
  30. int i = 0;
  31. for (NSString *typeName in items) {
  32. AUNavItemView *item = [[AUNavItemView alloc]initWithFrame:CGRectMake(0, 0, 0, 40)];
  33. item.itemTitle = typeName;
  34. item.isNavigationItem = NO;
  35. //支持iconfont
  36. // item.nomarlStateIconFontName = kICONFONT_USER_ADD;
  37. // if (i == 0 ) {
  38. //// item.badgeNumber = @"1";
  39. // UIImage *image = [UIImage imageNamed:@"ap_add_friend.png"];
  40. // item.nomarlStateIconImage = image;
  41. // } else if(i == 1) {
  42. //// item.badgeNumber = @"10";
  43. // UIImage *image = [UIImage imageNamed:@"ap_group_talk.png"];
  44. // item.nomarlStateIconImage = image;
  45. // } else if(i == 2) {
  46. //// item.badgeNumber = @"100";
  47. // UIImage *image = [UIImage imageNamed:@"ap_scan.png"];
  48. // item.nomarlStateIconImage = image;
  49. // } else if(i == 3) {
  50. //// item.badgeNumber = @"5";
  51. // UIImage *image = [UIImage imageNamed:@"ap_qrcode.png"];
  52. // item.nomarlStateIconImage = image;
  53. // } else if(i == 4) {
  54. // UIImage *image = [UIImage imageNamed:@"ap_help.png"];
  55. // item.nomarlStateIconImage = image;
  56. // }
  57. i++;
  58. [array addObject:item];
  59. }
  60. [AUFloatMenu showAtPostion:CGPointMake(0, 0) startOrignY:70 items:array];
  61. }
  62. - (void)onBarButtonClick:(id)sender
  63. {
  64. }
  65. @end