TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2017 |
Maintained by Busta117.
Easy custom searchBar
pod 'SBSearchBar'
#import "SBSearchBar.h"
@interface className : UIViewController <SBSearchBarDelegate>
- (void)SBSearchBarSearchButtonClicked:(SBSearchBar *)searchBar; // called when keyboard search button pressed
- (void)SBSearchBarCancelButtonClicked:(SBSearchBar *)searchBar; // called when cancel button is pressed
- (BOOL)SBSearchBarShouldBeginEditing:(SBSearchBar *)searchBar; // return NO to not become first responder
- (void)SBSearchBarTextDidBeginEditing:(SBSearchBar *)searchBar; // called when text starts editing
- (BOOL)SBSearchBarShouldEndEditing:(SBSearchBar *)searchBar; // return NO to not resign first responder
- (void)SBSearchBarTextDidEndEditing:(SBSearchBar *)searchBar; // called when text ends editing
SBSearchBar *searchBarCustom = [[SBSearchBar alloc] initWithFrame:CGRectMake(0, 0, 200, 35)]; //set your searchBar frame
searchBarCustom.delegate = self;
//if you need custom color, font, etc
[searchBarCustom setTextColor:[UIColor whiteColor]];
searchBarCustom.placeHolderColor = [UIColor whiteColor];
searchBarCustom.font = [UIFont fontWithName:@"Arial" size:14];
//you can set a custom lens image
searchBarCustom.lensImage = [UIImage imageNamed:@"ic_lens"];
//you can set a custom X image
searchBarCustom.cancelButtonImage = [UIImage imageNamed:@"FormReset"];
//you cand show an additional cancel button
searchBarCustom.addExtraCancelButton = YES;
[self.view addSubview:searchBarCustom];