自定义收索View
1 .h文件
@interface SearchNavView : UIView
@property (nonatomic, copy) void(^cancleBtnBlock)(void);
@property (nonatomic, copy) void(^textFiledEditingBlock)(NSString *contentStr);
@end
2 .m文件
#import "SearchNavView.h"
@interface SearchNavView()<UITextFieldDelegate>
@property (nonatomic, strong) UITextField *searchTextFiled;
@property (nonatomic, strong) UIButton *cancleBtn;
@end @implementation SearchNavView - (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self addSubview:self.searchTextFiled];
[self addSubview:self.cancleBtn];
_searchTextFiled.delegate = self;
}
return self;
}
- (void)layoutSubviews
{
[super layoutSubviews];
__weak typeof(self)weakself = self;
[self.searchTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(weakself.mas_centerY);
make.left.equalTo(weakself.mas_left).offset( / WIDTH_6S_SCALE);
make.width.mas_equalTo( / WIDTH_6S_SCALE);
make.height.mas_equalTo( / HEIGHT_6S_SCALE);
}];
_searchTextFiled.layer.cornerRadius = ;
_searchTextFiled.layer.masksToBounds = YES;
[self.cancleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(weakself.mas_centerY);
make.right.equalTo(weakself.mas_right).offset(- / WIDTH_6S_SCALE);
make.width.mas_equalTo( / WIDTH_6S_SCALE);
make.height.mas_equalTo( / HEIGHT_6S_SCALE);
}];
}
#pragma mark -UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if (self.textFiledEditingBlock) {
self.textFiledEditingBlock(self.searchTextFiled.text);
}
}
#pragma mark - event
- (void)cancleBtnAction
{
if (self.cancleBtnBlock) {
self.cancleBtnBlock();
}
}
#pragma mark - init
- (UITextField *)searchTextFiled
{
if (!_searchTextFiled) {
_searchTextFiled = [[UITextField alloc]init];
_searchTextFiled.backgroundColor = getColor(bgColor);
_searchTextFiled.font = DEF_FontSize_14;
_searchTextFiled.textColor = getColor(textColor);
_searchTextFiled.textAlignment = NSTextAlignmentCenter;
_searchTextFiled.placeholder = @"请输入搜索关键词";
}
return _searchTextFiled;
}
- (UIButton *)cancleBtn
{
if (!_cancleBtn) {
_cancleBtn = [[UIButton alloc]init];
_cancleBtn.backgroundColor = [UIColor clearColor];
[_cancleBtn setTitleColor:getColor(textColor) forState:UIControlStateNormal];
_cancleBtn.titleLabel.font = DEF_FontSize_14;
[_cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
[_cancleBtn addTarget:self action:@selector(cancleBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _cancleBtn;
}
@end
自定义收索View的更多相关文章
- 自定义控制器的View(loadView)及其注意点
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- 贝塞尔曲线:原理、自定义贝塞尔曲线View、使用!!!
一.原理 转自:http://www.2cto.com/kf/201401/275838.html Android动画学习Demo(3) 沿着贝塞尔曲线移动的Property Animation Pr ...
- 20170712 SQL Server 日志文件收索
-- 1 日志文件增长过快,未进行任务计划截断备份 造成文件过大199G 左右,而可用空间不足8% -- 2 日志备份之前,需要一次完整备份 再进行截断备份 出现可用空间99% 此时可以选择收索数据库 ...
- android显示通知栏Notification以及自定义Notification的View
遇到的最大的问题是监听不到用户清除通知栏的广播.所以是不能监听到的. 自定义通知栏的View,然后service运行时更改notification的信息. /** * Show a notificat ...
- 剑指offer-第四章解决面试题思路(二叉收索树和双向链表)
题目:输入一个二叉收索树,将二叉搜索树转换成排序的双向链表.要求不能创建节点,只能将链表中的指针进行改变. 将复杂的问题简单化:思路:二叉收索树,本身是一个排序结构,中序遍历二叉收索树就可以得到一组排 ...
- Android中自定义样式与View的构造函数中的第三个参数defStyle的意义
零.序 一.自定义Style 二.在XML中为属性声明属性值 1. 在layout中定义属性 2. 设置Style 3. 通过Theme指定 三.在运行时获取属性值 1. View的第三个构造函数的第 ...
- Android自定义View4——统计图View
1.介绍 周末在逛慕课网的时候,看到了一张学习计划报告图,详细记录了自己一周的学习情况,天天都是0节课啊!正好在学习Android自定义View,于是就想着自己去写了一个,这里先给出一张慕课网的图,和 ...
- 自定义android RadioButton View,添加较为灵活的布局处理方式
android的RadioButton的使用历来都让人比较头疼,如在布局方面,图案.文字无法分别设置padding等,另外,低版本的android RadioGroup不支持换行排列的RadioBut ...
- 自定义View_1_关于View,ViewGroup的测量和绘制流程
自定义View(1) ------ 关于View,ViewGroup的测量和绘制流程 在Android当中,自定义控件属于比较高级的知识体系,今天我们就一起研究研究关于自定义View的那点事,看看它到 ...
随机推荐
- 关于4Ps 、4Cs 、4Rs 、4Vs营销策略的内容及优劣比较
- JavaWeb浏览器传值乱码
在Java服务接口调用中,可能会出现乱码,如下图所示: 这是由编码不一致而致的乱码,可转,如下: name = new String(name.getBytes("ISO-8859-1&qu ...
- Flask内置命令行工具—CLI
应用发现 flask命令在Flask库安装后可使用,使用前需要正确配置FLASK_APP环境变量以告知用户程序所在位置.不同平台设置方式有所不同. Unix Bash (Linux, Mac, etc ...
- UOJ Easy Round#7
UOJ Easy Round#7 传送门:http://uoj.ac/contest/35 题解:http://matthew99.blog.uoj.ac/blog/2085 #1 题意: 在一个(2 ...
- charles抓取线上接口数据替换为本地json格式数据
最近要做下拉刷新,无奈测试服务器的测试数据太少,没有足够的数据做下拉刷新,所以用charles抓取了测试服务器的接口,然后在伪造了很多数据返回到我的电脑上,下面来说说使用方法: 第一步: 安装FQ软件 ...
- LightOJ1213 Fantasy of a Summation —— 快速幂
题目链接:https://vjudge.net/problem/LightOJ-1213 1213 - Fantasy of a Summation PDF (English) Statisti ...
- hdu-4857 逃生(拓扑序)
题目链接: 逃生 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Proble ...
- 51nod最长递增路径:(还不错的图)
一个无向图,可能有自环,有重边,每条边有一个边权.你可以从任何点出发,任何点结束,可以经过同一个点任意次.但是不能经过同一条边2次,并且你走过的路必须满足所有边的权值严格单调递增,求最长能经过多少条边 ...
- Gibonacci number-斐波那契数列
Description In mathematical terms, the normal sequence F(n) of Fibonacci numbers is defined by the r ...
- Spring-SpringMVC-Mybatis实例
源码下载:https://pan.baidu.com/s/1kUK7qYj 提取码:3mgb 最近在学习SSM框架,先讲一下这三大框架都有什么作用. SpringMVC: 它用于web层,相当于 ...