CGFloat enterW = self.view.frame.size.width - 80;// 245;
    CGFloat y = 0;
    containerView = [[UIView alloc] initWithFrame:CGRectMake(0, y, self.view.frame.size.width, 40)];
    [self.view addSubview:containerView];
    
    
    textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 5, enterW-10, 30)];
    textField.font = [UIFont systemFontOfSize:18.0f];
    textField.returnKeyType = UIReturnKeyDone;
    textField.clearButtonMode = UITextFieldViewModeWhileEditing; //显示一次性删除按钮
    textField.backgroundColor = [UIColor whiteColor];
    textField.layer.borderWidth = 1.0;
    textField.layer.cornerRadius = 5.0;
    textField.layer.borderColor = [UIColor lightGrayColor].CGColor; //显示边框颜色
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; //控件居中
    textField.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"searchIcon"]];
    textField.leftView.contentMode=UIViewContentModeCenter;  //显示左边放大镜
    textField.autoresizingMask = UIViewAutoresizingFlexibleWidth;

[containerView addSubview:textField];
 
    
    UIButton *uploadBtn = [[UIButton alloc] init];
    uploadBtn.frame = CGRectMake(self.view.frame.size.width - 70 - 5, 5, 70, 30);
    [uploadBtn setTitle:@"搜索" forState:UIControlStateNormal];
    [uploadBtn successStyle];

[uploadBtn addTarget:self action:@selector(uploadBtnPressed) forControlEvents:UIControlEventTouchUpInside];

[containerView addSubview:uploadBtn];

[containerView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
    
    NSLog(@"containerView y %f", containerView.frame.origin.y);

 

新建搜索bar的更多相关文章

  1. iOS搜索框

    在iOS8以前搜索框是作为一个控件添加到TableViewController中, 有系统自带的搜索变量self.searchDisplayController 遵守一个搜索显示的协议<UISe ...

  2. SharePoint 2013 配置启用搜索服务

    原文:SharePoint 2013 配置启用搜索服务 1.安装完毕SharePoint 2013,新建网站集,点击搜索,出现如下错误(因为没配置,别激动). 2.尝试启动服务器场中的服务之Share ...

  3. SharePoint 2013配置启用搜索服务

    1.安装完毕SharePoint 2013,新建网站集,点击搜索,出现如下错误(因为没配置,别激动). 2.尝试启动服务器场中的服务之SharePoint Server Search,提示新建搜索应用 ...

  4. Sharepoint 2013搜索服务配置总结(实战)

    分享人:广州华软 星尘 一. 前言 SharePoint 2013集成了Fast搜索,相对于以前版本搜索的配置有了一些改变,在安装部署Sharepoint 2013时可以选择默认创建搜索服务,但有时候 ...

  5. Windows下的搜索神器 —— everything

    介绍一款Windows下的神奇 -- everything,软件很小巧,但是搜索速度非常快,比Windows自带的搜索功能更强大.更快.掌握它的基本用法,在查找文件时能提升很高的效率 1.下载 2.基 ...

  6. Solr搜索器的特性及相关操作

    一.搜索处理器简介 所有的请求处理器都实现一个Java类,本例实现了solr.SearchHandler.在运行时,solr.SearchHandler被解析为内置的Solr类org.apache.s ...

  7. SharePoint 2013 Search 配置总结

    前言:SharePoint 2013集成了Fast搜索以后,搜索的配置有了些许改变,自己在配置过程中,也记录下了一些入门的东西,希望能够对大家有所帮助. 1.配置搜索服务,首先需要启用搜索功能,基本思 ...

  8. [转]你不需要jQuery

    完全没有否定jQuery的意思,jQuery是一个神奇的.非常有用的工具,可以节省我们大量的时间. 但是,有些时候,我们只需要jQuery的一个小功能,来完成一个小任务,完全没有必要加载整个jQuer ...

  9. UIView---汇总

    视图.绘图.贴图.手势.变形.布局.动画.动力.特效 UIBezierPath.UIGestureRecognizer.CGAffineTransform.frame.bounds.center.tr ...

随机推荐

  1. 图解SQL的各种连接join[转]

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...

  2. Rest风格WEB服务(Rest Style Web Service)的真相

    http://blog.csdn.net/jia20003/article/details/8365585 Rest风格WEB服务(Rest Style Web Service)的真相 分类: J2E ...

  3. OC中的self指针

    在OC中,self是一个指针,方法和属性可以通过self.function进行访问:成员变量使用self->变量名进行访问.调用方法还可以用[self function]; OC中的self有点 ...

  4. 【shell】条件判断式

    条件判断式的表示格式: 文件判断式: [root@andon ~]# [ -e /root/1 ] && echo yes || echo no #注意[]里面的空格,第一个命令为真打 ...

  5. PHP替换,只替换匹配到的第一个

    function str_replace_limit($search, $replace, $subject, $limit=-1) { if (is_array($search)) { foreac ...

  6. Axure RP

    Axure RP是一个专业的快速原型设计工具.Axure(发音:Ack-sure),代表美国Axure公司:RP则是Rapid Prototyping(快速原型)的缩写. Axure RP是美国Axu ...

  7. [platform]新旧内核的device设备注册对比

    转自:http://blog.chinaunix.net/uid-7332782-id-3268801.html 1. Version2.6内核启动过程 start_kernel( ) //板子上电启 ...

  8. 事件日志ID 2511:服务器服务无法重新创建 <sharename> 共享关系,因为 <address> 目录已不再存在

    服务器服务无法重新创建 QQMusicDownload 共享关系,因为 D:\QQMusic\QQMusicDownload 目录已不再存在.请运行 "net share QQMusicDo ...

  9. (C/C++) Callback Function 回调(diao)函数

    原文: http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557/Callback-Functions-Tutorial ...

  10. mysql小问题

    报错信息如下: 主要是因为用root用户登录查询其他用户的表,结果这个用户不存在了,所以导致没有权限.临时解决办法,给root赋所有权限: grant all privileges on *.* to ...