All Products
Search
Document Center

Mobile Platform as a Service:Custom navigation bar

Last Updated:Jul 19, 2023

AUCustomNavigationBar is a navigation bar component customized by mPaaS for the transparent navigation bar scenario.

After the native navigation bar is changed from transparent to solid, users may have bad visual experience. This class is provided for avoiding this issue.

API description

    /**
 Customize a transparent navigation bar as required.
 After the native navigation pane is changed from transparent to solid, users may have bad visual experience. This class is provided for avoiding this issue.
 */
@interface AUCustomNavigationBar : UIView

@property(nonatomic, strong) UIView *backgroundView;              // Ground glass background view.

@property(nonatomic, strong) NSString *backButtonTitle;           // The back button title (no title by default).
@property(nonatomic, strong) UIColor *backButtonTitleColor;       // The title color of the back button.
@property(nonatomic, strong) UIImage *backButtonImage;            // The image of the back button.

@property(nonatomic, strong) NSString *title;                     // The title.
@property(nonatomic, strong) UIColor *titleColor;                 // The title color.
@property(nonatomic, strong) UIView *titleView;                   // Customized titleview.

@property(nonatomic, strong) NSString *rightItemTitle;            // The right item title.
@property(nonatomic, strong) UIColor *rightItemTitleColor;        // The color of the right item title.
@property(nonatomic, strong) UIImage *rightItemImage;             // The image of the right item.

/**
 * The VoiceOver text for the item displayed on the right.
 * The item displayed on the left, which is "Back" by default.
 * The item displayed on the right, which is specified by rightItemTitle by default. If rightItemTitle is not set, manually set this property to support VoiceOver.
 */
@property(nonatomic,strong) NSString *rightItemVoiceOverText;

@property(nonatomic,strong) NSString *leftItemVoiceOverText;


/**
 *  Create a specified view of transparent navigation bar. 
 *
 *  (1) By default, the navigation bar displays an arrow instead of "Back" on the left for users to go back. If the current page needs to set the back text that is consistent with the framework logic, override the (UIView *)customNavigationBar method in VC.
 *  (2) To set the title, item to be displayed on the right, and background in frosted glass effect, call related APIs.
 *
 *  @param currentVC The current VC.
 *
 *  @return The view of transparent navigation bar.
 */
 + (AUCustomNavigationBar *)navigationBarForCurrentVC:(UIViewController *)currentVC;

/**
 *  Set the background view of frosted glass. The transparency is 0 by default.
 */
- (void)setNavigationBarBlurEffective;

/**
 *  Create an item to be displayed on the right of the navigation bar.
 *
 *  @param rightItemTitle    Displayed text.
 *  @param target            target
 *  @param action            action
 *
 */
- (void)setNavigationBarRightItemWithTitle:(NSString *)rightItemTitle target:(id)target action:(SEL)action;

 /**
 *  Create an item to be displayed on the right of the navigation bar.
 *
 *  @param rightItemImage    Displayed image.
 *  @param target            target
 *  @param action            action
 *
 */
- (void)setNavigationBarRightItemWithImage:(UIImage *)rightItemImage target:(id)target action:(SEL)action;


/**
 *  Create an item to be displayed on the left of the navigation bar.
 *
 *  @param leftItemTitle     Displayed text.
 *  @param target            target
 *  @param action            action
 *
 */
- (void)setNavigationBarLeftItemWithTitle:(NSString *)leftItemTitle target:(id)target action:(SEL)action;

/**
 *  Create an item to be displayed on the left of the navigation bar.
 *
 *  @param leftItemTitle     Displayed image.
 *  @param target            target
 *  @param action            action
 *
 */
- (void)setNavigationBarLeftItemWithImage:(UIImage *)leftItemTitle target:(id)target action:(SEL)action;


@end

Sample code

AUCustomNavigationBar *navBar = [AUCustomNavigationBar navigationBarForCurrentVC:self];
[navBar setNavigationBarBlurEffective]; // The frosted glass effect.
[self.view addSubview:navBar];
navBar.title = @"Title";
navBar.backButtonImage = [AUIconView iconWithName:kICONFONT_BILL width:22 color:AU_COLOR_LINK];
navBar.backButtonTitle = @"Bill";
navBar.rightItemImage = [AUIconView iconWithName:kICONFONT_ADD width:22 color:AU_COLOR_LINK];

// When using this API on mPaaS, override the following methods of the parent class:
- (BOOL)autohideNavigationBar
{
        return YES;
}
- (UIView *)customNavigationBar
{
        return self.navBar;
}