SBSearchBar 0.0.7

SBSearchBar 0.0.7

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年4月

Busta117 维护。



  • 作者:
  • Santiago Bustamante

简单的自定义搜索栏

Podfile

pod 'SBSearchBar'

如何使用

  • 在您的代码中导入 SBSearchBar.h
#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];

反馈?