SBSearchBar 0.0.7

SBSearchBar 0.0.7

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2017

Maintained by Busta117.



  • By
  • Santiago Bustamante

Easy custom searchBar

Podfile

pod 'SBSearchBar'

How to use

  • in your code import SBSearchBar.h
#import "SBSearchBar.h"
  • implement delegate in your class
@interface className : UIViewController <SBSearchBarDelegate>
  • add delegate methods
- (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
  • in your code add follow code when you need show the SearchBar
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];

feedback?