Latest 0.0.7
Homepage https://github.com/adampei/AwSearch
License MIT
Platforms ios 8.0, requires ARC
Dependencies Masonry
Authors

一款简易自定义搜索框支持pods安装

简介: 完全自定义的搜索框, 搜索icon图片可以更改, icon大小, 边距可变.placeholder颜色,字体大小可变.textfield输入框字体大小颜色可变.搜索整个背景颜色, 边距, 圆角等可变; 右侧按钮可设置图片, 边距等

用法以及注意事项

  • 注意: 此库依赖Masonry

初始化

AwSearch * searchView = [[AwSearch alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 55)];

设置不通的搜索图片如下图

  • 属性iconName
    // 设置icon
    // 图片
    searchView.iconName = @"search_icon_white"; //search_icon_white search_icon

    image
    image

设置图片的内边距

  • 通过设置属性insetsIcon
    // icon 位置
    //searchView.insetsIcon = UIEdgeInsetsMake(0, 30, 0, 0);

    image
    image

设置placeholder颜色以及字体大小

  • 设置placeholder内容通过属性 placeHolder
    // 设置placehodler
    searchView.placeHolder = @"请输入要搜索的内容";
  • 设置placeholder颜色colorPlaceholder
    /// placeholder 颜色
    //searchView.colorPlaceholder = [UIColor yellowColor];
  • 设置placehodler字体大小cusFontPlaceHolder
    /// placeholder 字体大小
    searchView.cusFontPlaceHolder = 20;

    image
    image
    image

设置输入框背景色, 圆角, 以及边距

  • 设置背景色colorSearchBg
//设置搜索框背景色
//searchView.colorSearchBg = [UIColor orangeColor];
  • 设置边距insetsSearchBg
/// 设置灰色背景边距
//searchView.insetsSearchBg = UIEdgeInsetsMake(0, 0, 0, 0);
  • 设置圆角raidus
/// 圆角
//searchView.raidus = 10;

image
image
image

输入框字体颜色, 大小, 以及边距

  • 字体颜色colorTxtInput
// textfield 字体颜色
//searchView.colorTxtInput = [UIColor redColor];
  • 字体大小cusFontTxt
// textfield 字体大小
//searchView.cusFontTxt = 20;
  • 输入框边距insetsTxtfield
/// 设置txtfield边距 左侧距离icon 其他距离灰色背景
//searchView.insetsTxtfield = UIEdgeInsetsMake(10, 10, 20, 50);

image
image
image
image

设置右侧按钮字体颜色, 背景色, 背景图片, 图片, 标题等这里只列举部分图片展示

  • 按钮图片imgBtn
/// 按钮图片
//searchView.imgBtn = @"search_icon_white";
  • 标题titleBtn
// 标题
searchView.titleBtn = @"确定";
  • 字体颜色colorTitleBtn
/// 颜色
//searchView.colorTitleBtn = [UIColor redColor];
  • 按钮背景图imgBtnBg
/// 按钮背景图片
//searchView.imgBtnBg = @"search_icon";
  • 按钮边距insetsBtn
/// 按钮边距
//searchView.insetsBtn = UIEdgeInsetsMake(5, 10, 10, 20);
  • 按钮字体大小fontBtn

image
image

事件回调

  • 点击键盘中的搜索回调
  • 其中设置键盘右下角样式通过属性returnType
    [searchView setClickSearchCallback:^(NSString *keyword) {
    NSLog(@"点击键盘搜索: %@",keyword);
    }];
    // 点击右侧按钮回调
    [searchView setClickRightBtnCallback:^{
    NSLog(@"点击右侧按钮");
    }];
    // 每输入一个文字的回调
    [searchView setTxtfieldEditingCallback:^(NSString *text) {
    NSLog(@"输入的内容: %@", text);
    }];

Latest podspec

{
    "name": "AwSearch",
    "version": "0.0.7",
    "summary": "u4e00u4e2au8f7bu91cfu7ea7u7684u641cu7d22u6846",
    "description": "u4e00u4e2au5b8cu5168u81eau5b9au4e49u8f7bu91cfu7ea7u641cu7d22u6846",
    "homepage": "https://github.com/adampei/AwSearch",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u88f4u6ce2u6ce2": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/adampei/AwSearch.git",
        "tag": "0.0.7"
    },
    "source_files": "demo/demo/AwSearch",
    "requires_arc": true,
    "dependencies": {
        "Masonry": [
            "~> 1.1.0"
        ]
    }
}

Pin It on Pinterest

Share This