Developer

MAFUISearchBar

MAFUISearchBar extends the native UISearchBar class with MAF styling capability using the MAFStyling protocol.

The differences between the native and the SAP-style-based controls are shown here:

Comparison of Native and MAF UISearchBar

Figure 12: Comparison of Native and MAF UISearchBar
To create MAFUISearchBar with the default SAP style and add it to the view of your ViewController, use:
MAFUISearchBar *styledSearchBar = [[MAFUISearchBar alloc] initWithFrame:CGRectMake(40, 165, 250, 45)];
        [mafUIView addSubview:styledSearchBar];
        [styledSearchBar release];
		[mafUIView release];
You can style the background of the search bar to any gradient or simple color. You can also customize the font style and the search icon with the styling XML:
<Style targettype="SearchBar" key="SampleSearchBar" platform="ios">
     <BackgroundImage height="30" imagesource="imageFile1.png" width="30">
     <SearchBarIcon height="30" imagesource="imageFile2.png" width="30">
     <SearchFieldBackgroundImage height="30" imagesource="imageFile3.png" width="30">
     <Setter property="TextColor" value="#006666">
     <Setter property="FontFamily" value="Helvetica-Bold">
     <Setter property="FontSize" value="14">
     <Setter property="BarStyle" value="1">
     <Setter property="TintColor" value="#330099">
     <Setter property="Translucent" value="NO">
</Style>
To apply this style, set the style name of the MAFUISearchBar instance to “SampleSearchBar”:
[styledSearchBar setMafStyleName:@"SampleSearchBar"];
You can change these properties in the skinning XML:
Background The background image for the search bar.
SearchBarIcon The image to use for the search bar icon.
FontFamily The font family of the text in the search bar.
FontSize The font size of the text in the search bar.
TextColor The color of the text in the search bar.
SearchFieldBackgroundImage The image to use for the background of the search bar.
BarStyle The style that specifies the receiver’s appearance. Possible values: UIBarStyleDefault, UIBarStyleBlack, UIBarStyleBlackOpaque.
TintColor The tint color of the search bar.
Translucent Specifies whether the receiver is translucent. Sets the native property of the search bar.