All Products
Search
Document Center

Search input box

Last Updated: May 25, 2021

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.

Sample image

Dependency

The dependency of AUSearchTitleView is as follows:

 
  1. AntUI(iOS)
  2. 1.0.0.161108003457
  3. APCommonUI(iOS)
  4. 1.2.0.161108102201

API description

 
  1. typedef NS_ENUM(NSInteger, AUSearchTitleStyle) {
  2. AUSearchTitleStyleDefault = 0, // Search box with black text, which is applicable when a light color background is used.
  3. AUSearchTitleStyleMiddleAlign, // Search box with centered black text, which is applicable when a light color background is used.
  4. AUSearchTitleStyleContent, // Search box with white text, which is applicable when a deep color background is used.
  5. };
  6. @class AUSearchTitleView;
  7. @protocol AUSearchTitleViewDelegate <NSObject>
  8. @optional
  9. // The search bar control.
  10. - (void)didPressedTitleView:(AUSearchTitleView *)titleView;
  11. // The voice icon of the search bar control.
  12. - (void)didPressedVoiceButton:(AUSearchTitleView *)titleView;
  13. @end
  14. /**
  15. The search bar control. (The width is the same as that of the screen by default.)
  16. */
  17. @interface AUSearchTitleView : UIView
  18. @property(nonatomic, assign)AUSearchTitleStyle style; // The background style of the search box. The light color background is used by default
  19. @property(nonatomic,strong) NSString *placeHolder; // The search box placeholder, which is "Search" by default.
  20. @property(nonatomic,strong) UIColor *placeHolderColor; // The text color of the search box placeholder.
  21. @property (nonatomic, weak) id<AUSearchTitleViewDelegate> delegate;
  22. @property(nonatomic,strong) UIImage *searchIconImage; // The search icon.
  23. @property(nonatomic,strong) UIColor *normalBackgroundColor; // The background color of the search box.
  24. @property(nonatomic,assign) BOOL isShowVoiceIcon; // Whether to display the Voice icon. Default value: No.
  25. /**
  26. * 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.
  27. * 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.
  28. *
  29. * If there are any special requirements, change the padding.
  30. *
  31. */
  32. @property(nonatomic,assign) CGFloat marginBetweenItem;
  33. /**
  34. * The method for getting the instance.
  35. *
  36. * @param style The search box style.
  37. *
  38. * @return Return the instance.
  39. */
  40. - (id)initWithSearchStyle:(AUSearchTitleStyle)style;
  41. /**
  42. * 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.
  43. */
  44. - (void)onClicked;
  45. @end

Code sample

  • Used in a navigation bar
 
  1. AUSearchTitleView *titleView = [[AUSearchTitleView alloc] initWithSearchStyle:AUSearchTitleStyleDefault];
  2. titleView.placeHolder = @"The search bar style";
  3. titleView.placeHolderColor = [UIColor blackColor];
  4. titleView.normalBackgroundColor = [UIColor orangeColor];
  5. titleView.isShowVoiceIcon = YES;
  6. titleView.delegate = self;
  7. self.navigationItem.titleView = titleView;
  • Used in a common view
 
  1. titleView = [[AUSearchTitleView alloc] initWithSearchStyle:AUSearchTitleStyleMiddleAlign];
  2. titleView.placeHolder = @"The AUSearchTitleStyleMiddleAlign style";
  3. titleView.isShowVoiceIcon = YES;
  4. titleView.delegate = self;
  5. [self.view addSubview:titleView];