自定义收索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的那点事,看看它到 ...
随机推荐
- Hibernate主要查询方式
1.hql查询 1.1 无参数的hql查询 1.2 带参的hql查询(分为问号占位和字符占位两种) Ps: 绑定各种类型的参数时用setParameter()绑定参数,如封装方法后用不定参数时循环绑定 ...
- machine learning for hacker记录(2) 数据分析
本章主要讲了对数据的一些基本探索,常见的six numbers,方差,均值等 > data.file <- file.path('data', '01_heights_weights_ge ...
- chatty: uid=10549(u0_a549) com.exampleidentical 40 lines
主要是因为你的app在短时间内输出太多次的日志,导致日志丢失 As soon as app considered 'chatty' by logcat (more than 5 lines per s ...
- contentprovider 实例
Provider端 public class PersonProvider extends ContentProvider { //用来存放所有合法的Uri的容器 private static Uri ...
- 关于Ajax实现的简单示例
一.代码示例 关于Ajax的基本概念(包括XMLHttpRequest对象及其相关方法属性)移步这里(w3school中文版)学习了解. <!doctype html> <html ...
- Jmeter创建一个简单的http接口用例
1.新建线程组 添加->Threads(Users)->线程组 线程组用来模拟用户进程. 2.添加http信息头管理器 添加->配置元件->http信息头管理器 Systemi ...
- html5--3.4 input元素(3)
html5--3.4 input元素(3) 学习要点 input元素及其属性 input元素 用来设置表单中的内容项,比如输入内容的文本框,按钮等 不仅可以布置在表单中,也可以在表单之外的元素使用 i ...
- ansible管理windows实践
一.前言 近期打算搞搞自动部署,因为是windows服务器,一些工具和系统支持都不是太好.最后发现ansible比较火,最重要的是他支持windows.本文主要就ansible 在windows使用环 ...
- 矩阵管理——和visitor模式没有本质区别,都是为了避免资源重复
矩阵管理中的员工是双线汇报的模式.其上司有两个,一个是流程上司,一个是专业上司.流程上司负责你的日常考核,专业上司负责你的晋升和任免. 管理条件 相对于矩阵管理的矩阵式组织,适合于某些较为庞大的全球性 ...
- codeforces 702D D. Road to Post Office(数学)
题目链接: D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input ...