All Products
Search
Document Center

Mobile Platform as a Service:Search input box

Last Updated:Jul 18, 2023

AUSearchTitleView is a search bar control. It is similar to a search bar but can only be tapped. It supports the following styles:

  • AUSearchTitleStyleDefault = 0: search box with black text, which is applicable when a light color background is used.

    Example: search box displayed on the navigation pane on an mPaaS app page.

  • AUSearchTitleStyleMiddleAlign: search box with centered black text, which is applicable when a light color background is used.

    Example: search box on the contact page.

  • AUSearchTitleStyleContent: search box with white text, which is applicable when a deep color background is used

    Example: search box displayed on the navigation pane on the mPaaS app homepage.

Dependency

The dependency of AUSearchTitleView is as follows:

    AntUI(iOS)
    1.0.0.161108003457
    APCommonUI(iOS)
    1.2.0.161108102201

API description

    typedef NS_ENUM(NSInteger, AUSearchTitleStyle) {
        AUSearchTitleStyleDefault = 0,    // Search box with black text, which is applicable when a light color background is used.
        AUSearchTitleStyleMiddleAlign,    // Search box with centered black text, which is applicable when a light color background is used.
        AUSearchTitleStyleContent,        // Search box with white text, which is applicable when a deep color background is used.
};

@class AUSearchTitleView;

@protocol AUSearchTitleViewDelegate <NSObject>

@optional

// The search bar control.
- (void)didPressedTitleView:(AUSearchTitleView *)titleView;

// The voice icon of the search bar control.
- (void)didPressedVoiceButton:(AUSearchTitleView *)titleView;

@end



/**
The search bar control. (The width is the same as that of the screen by default.)
*/
@interface AUSearchTitleView : UIView

@property(nonatomic, assign)AUSearchTitleStyle style;         // The background style of the search box. The light color background is used by default

@property(nonatomic,strong) NSString *placeHolder;            // The search box placeholder, which is "Search" by default.
@property(nonatomic,strong) UIColor *placeHolderColor;        // The text color of the search box placeholder.

@property (nonatomic, weak) id<AUSearchTitleViewDelegate> delegate;

@property(nonatomic,strong) UIImage *searchIconImage;         // The search icon.
@property(nonatomic,strong) UIColor *normalBackgroundColor;   // The background color of the search box.
@property(nonatomic,assign) BOOL isShowVoiceIcon;             // Whether to display the Voice icon. Default value: No.


/**
* The padding to the left and right of the outer-layer transparent view. The default value is 9. To configure the space between the view of the instance to be initialized and another view for a business, consider the padding as well to prevent a visual error.
* Note: If the instance to be initialized is defined as the titleView of a navigationItem, the system specifies the spacing between the titleView and the views on its left and right in an adaptive manner. To meet the visual requirements, the system sets the padding between the search box and the outer-layer view. 
*
* If there are any special requirements, change the padding.
*
*/
@property(nonatomic,assign) CGFloat marginBetweenItem;

/**
*  The method for getting the instance.
*
*  @param style The search box style.
*
*  @return      Return the instance.
*/
- (id)initWithSearchStyle:(AUSearchTitleStyle)style;

/**
 *  This method calls the global search page by default. To define the event of tapping the search box for a business, override this method in the subclass.
 */
- (void)onClicked;

@end

Code sample

  • Used in a navigation bar

AUSearchTitleView *titleView = [[AUSearchTitleView alloc] initWithSearchStyle:AUSearchTitleStyleDefault];
    titleView.placeHolder = @"The search bar style";
    titleView.placeHolderColor = [UIColor blackColor];
    titleView.normalBackgroundColor = [UIColor orangeColor];
    titleView.isShowVoiceIcon = YES;
    titleView.delegate = self;
    self.navigationItem.titleView = titleView;
  • Used in a common view

titleView = [[AUSearchTitleView alloc] initWithSearchStyle:AUSearchTitleStyleMiddleAlign];
    titleView.placeHolder = @"The AUSearchTitleStyleMiddleAlign style";
    titleView.isShowVoiceIcon = YES;
    titleView.delegate = self;
    [self.view addSubview:titleView];