All Products
Search
Document Center

Navigation bar

Last Updated: May 25, 2021

AUNavigationBar is a navigation bar control of mPaaS. It extends the UINavigationBar control and provides default mPaaS navigation bar styles.To facilitate subsequent extension, use AUNavigationBar rather than UINavigationBar in all mPaaS apps.

Sample image

API description

 
  1. /**
  2. The mPaaS navigation bar control that contains mPaaS navigation bar styles.
  3. Initialize:
  4. UINavigationController *navBar = [[UINavigationController alloc] initWithNavigationBarClass:NSClassFromString(@"AUNavigationBar") toolbarClass:nil];
  5. */
  6. @interface AUNavigationBar : UINavigationBar
  7. @end
  8. /**
  9. The UINavigationBar extension that defines default UINavigationBar styles.
  10. */
  11. @interface UINavigationBar (AUNavigationBarExtensions)
  12. /**
  13. * Return the default color of the title of framework navigation bar. The default value is #000000.
  14. *
  15. * @return
  16. */
  17. + (UIColor*)getNavigationBarTitleDefaultColor;
  18. /**
  19. * Return the color of the item of framework navigation bar. The default value is #108EE9.
  20. *
  21. * @return
  22. */
  23. + (UIColor*)getNavigationBarButtonItemDefaultColor;
  24. /**
  25. * Return the color of the item of framework navigation bar. The default value is #fffff.
  26. *
  27. * @return
  28. */
  29. + (UIColor*)getNavigationBarDefaultColor;
  30. /**
  31. * Get the color of the bottom line of the navigation bar. The default value is #e1e1e1.
  32. *
  33. * @return
  34. */
  35. + (UIColor*)getNavigationBarBotLineColor;
  36. /**
  37. * Note:
  38. * 1. The base class DTViewController sets the default style of navigation bar in ViewWillAppear.
  39. * 2. Business personnel can call the system APIs or the following APIs to change the style of navigation bar. The style is typically set in ViewWillAppear.
  40. * 3. If VC is a subclass of DTViewController, it must be set in ViewWillAppear, or it will be overridden.
  41. * 4. Ensure that setNavigationBarDefaultStyle is used to restore the default style when ViewWillDisappear is called after the modification.
  42. * 5. If VC defines the homepage in the UITabBarController container, do not use setNavigationBarDefaultStyle to restore the default style, or the VC will be overridden upon tab switching.
  43. */
  44. /**
  45. *
  46. * Set the background of default navigation bar. The default background color and bottom line color are #ffffff and #e1e1e1, respectively.
  47. *
  48. */
  49. - (void)setNavigationBarDefaultStyle;
  50. /**
  51. *
  52. * Set the default title style of the navigation bar.
  53. *
  54. */
  55. - (void)setNavigationBarDefaultTitleTextAttributes;
  56. /**
  57. *
  58. * Set the title color of the navigation bar in ViewWillAppear, or the title color will be overridden by the default title color in the framework.
  59. *
  60. */
  61. - (void)setNavigationBarTitleTextAttributesWithTextColor:(UIColor *)textColor;
  62. /**
  63. *
  64. * Set the transparency of the navigation bar.
  65. * Note: If this method sets the navigation bar to be completely transparent, returned animation will flash white. Currently, this issue has not been resolved. Do not call this method. If the method is required, evaluate whether the impact is acceptable.
  66. */
  67. - (void)setNavigationBarTranslucentStyle;
  68. /**
  69. * Set the color of the navigation bar. To achieve the frosted glass effect, set translucent to Yes.
  70. * Note: After calling this API, call the bottom line setting API if necessary, or the bottom line color will be overridden by the default color #e1e1e1.
  71. *
  72. * @param color The color to be displayed.
  73. * @param translucent Whether to be transparent.
  74. *
  75. */
  76. - (void)setNavigationBarStyleWithColor:(UIColor *)color translucent:(BOOL)translucent;
  77. /**
  78. * There may be a separation line under the navigation bar, and the UI may fail to meet some UI requirements. Call this method to set the color of the separation line to prevent it from being recognized.
  79. * Note: If you have defined the background of navigation bar, for example, by calling setNavigationBarStyleWithColor or rewriting opaqueNavigationBarColor, call this API after changing the background color.
  80. * Otherwise, the bottom line color will be overridden by the default color #e1e1e1.
  81. */
  82. - (void)setNavigationBarBottomLineColor:(UIColor*)color;
  83. /**
  84. * Before calling the system methods setBarTintColor, setBackGroundImage, and setBackgroundColor to set the color of navigation bar, call this method to eliminate the default effect.
  85. * Otherwise, the color will be overlaid with the default color and cause a color deviation.
  86. */
  87. - (void)resetNavigationBarColor;
  88. /**
  89. *
  90. * To prevent the issue that the navigation bar flashes when a user swipes right to go back or cancel an operation, do not call this method.
  91. */
  92. - (void)setNavigationBarMaskLayerWithtColor:(UIColor *)color;
  93. /**
  94. * Return the current background color of the navigation bar.
  95. *
  96. * @return Return the current background color of the navigation bar.
  97. */
  98. - (UIColor*)getNavigationBarCurrentColor;
  99. @end

Sample code

 
  1. // Initialize UINavigationController.
  2. UINavigationController *navBar = [[UINavigationController alloc] initWithNavigationBarClass:NSClassFromString(@"AUNavigationBar") toolbarClass:nil];
  3. // Configure the navigation bar in VC.
  4. AUBarButtonItem *cancelItem = [AUBarButtonItem backBarButtonItemWithTitle:@"Back" target:self action:@selector(cancel)];
  5. cancelItem.backButtonTitle = @"Cancel";
  6. self.navigationItem.leftBarButtonItem = cancelItem;
  7. UIImage *image1 = [AUIconView iconWithName:kICONFONT_MAP width:22 color:AU_COLOR_LINK];
  8. UIImage *image2 = [AUIconView iconWithName:kICONFONT_HELP width:22 color:AU_COLOR_LINK];
  9. AUBarButtonItem *rightItem1 = [[AUBarButtonItem alloc] initWithImage:image1 style:UIBarButtonItemStylePlain target:self action:@selector(rightBarItemPressed)];
  10. AUBarButtonItem *rightItem2 = [[AUBarButtonItem alloc] initWithImage:image2 style:UIBarButtonItemStylePlain target:self action:@selector(rightBarItemPressed)];
  11. self.navigationItem.rightBarButtonItems = @[rightItem1, rightItem2];