UISearchBar(圆角、背景)

iOS小技能: UISearchBar 搜索框使用教程(1、设置_UISearchBarSearchFieldBackgroundView 控件的圆角2、去掉UISearchBar搜索框的放大镜) + (UISearchBar*)homesearchBar { UISearchBar *searchBar = [[UISearchBar alloc]init]; [searchBar setImage:[UIImage imageNamed:@"search"] forSearchBarIcon:UISearchBarIconSearch state:UICont 阅读详情


- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    UITapGestureRecognizer *tapGest = [[UITapGestureRecognizer alloc]init];
    [tapGest setNumberOfTapsRequired:1];
    [tapGest setNumberOfTouchesRequired:1];
    [tapGest addTarget:self action:@selector(tapGesut)];
    
    [self.view addGestureRecognizer:tapGest];
    
    search_Bar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 50, 320, 40)];
    search_Bar.delegate = self;
//    search_Bar.alpha = .5f;
    /**
     *  搜索框风格
     *  UISearchBarIconSearch/UISearchBarStyleProminent = UISearchBarStyleDefault  放大镜在中间,默认风格
     *  UISearchBarStyleMinimal  最小风格,没外层边框
     *
     */
    search_Bar.searchBarStyle = UISearchBarStyleMinimal;
    
    /**
     *  搜索框外层颜色
     */
    search_Bar.barTintColor = [UIColor lightGrayColor];
    
    
    /**
     *  光标、取消按钮颜色
     */
    search_Bar.tintColor = [UIColor redColor];
    

    /**
     *  居右的提示,输入后文字会消失
     */
    search_Bar.placeholder = @"2121";
    
    
    /**
     *  半透明
     *  ios 6默认是NO,但7中YES也没效果,要设置alphe 透明才可以
     */
    search_Bar.translucent = YES;
    
    
    /**
     * 键盘最上方的视图,你妹,找到宝了,这是加入到
     */
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
    view.backgroundColor = [UIColor redColor];
    search_Bar.inputAccessoryView = view;
    

    /**
     *  改变按钮图片,正常在选中方法里面处理,如果在这里处理,直接平铺到搜索框内
     */
//  [search_Bar setImage:[UIImage imageNamed:@"2"] forSearchBarIcon:UISearchBarIconBookmark state:UIControlStateNormal];

    
    [self.view addSubview:search_Bar];

    
//____________未核心功能_____________

     //搜索框内容
     //如果一开妈有值,程输入状态
//   search_Bar.text = @" ";
    

     //居中的提示文字,不会因为输入内容消失
//   search_Bar.prompt = @"12e";
    
    //
    [search_Bar setShowsScopeBar:YES];

    //跟searchBarStyle 感觉没什么用
//    search_Bar.barStyle = UIBarPositionTop;
    
    //直接setBackgroundImage效果一样,前提是 UISearchBarStyleMinimal 无外框类型
//    search_Bar.scopeBarBackgroundImage = [UIImage imageNamed:@"1"];

    //类似选择器,还不知道有什么用
//    search_Bar.scopeButtonTitles = @[@"2",@"3",@"5"];
    
    
    
}

//开始选中搜索框
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
    //显示在框外右侧 取消-按钮
//  [searchBar setShowsCancelButton:YES animated:YES];
    
    //显示在框内右侧 书-按钮
  [search_Bar setShowsBookmarkButton:YES];
  [search_Bar setImage:[UIImage imageNamed:@"2"] forSearchBarIcon:UISearchBarIconBookmark state:UIControlStateNormal];
    //显示在框内右侧 下拉箭头-按钮
//  [search_Bar setShowsSearchResultsButton:YES];
    
    
    return YES;
}

//点击取消-按钮还原搜索条大小
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    [search_Bar resignFirstResponder];
    [search_Bar setShowsCancelButton:NO animated:YES];
    
}

//点击书-按钮还原搜索条大小
-(void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar
{
    
    //选中改变图片
    [search_Bar setImage:[UIImage imageNamed:@"1"] forSearchBarIcon:UISearchBarIconBookmark state:UIControlStateNormal];

}

//点击下拉箭头-按钮还原搜索条大小
-(void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar
{
    [searchBar setSearchResultsButtonSelected:!searchBar.searchResultsButtonSelected];
}


//监测搜索框文字输入时执行
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    //实时获取搜索框内 信息
    
}

//点击键盘"搜索"执行
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    
}



//空白处理添加点击手势 收起键盘
-(void)tapGesut
{
    [search_Bar resignFirstResponder];
    [search_Bar setShowsCancelButton:NO animated:YES];
}




//当输入完 点击屏幕空白处认为是 不再输入,执行此方法
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
    //    [search_Bar resignFirstResponder];
    //    [search_Bar setShowsCancelButton:NO animated:YES];
}


http://www.cnblogs.com/-ios/p/5948643.html

/** 取消searchBar背景色 */

- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size

{

    CGRect rect = CGRectMake(0, 0, size.width, size.height);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

      return image;

}

 

然后在viewdidload里面

/** 设置背景图片 */

    [_searchBar setBackgroundImage:[UIImage imageNamed:@"red_nav_bar"]];   //这里图片的颜色和导航栏一样

/** 设置背景色 */

   [_searchBar setBackgroundColor:[UIColor redColor]];

/** 设置文本框背景 * 

[_searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"imageView"] forState:UIControlStateNormal];

 

 

    //更改search圆角

        UITextField *searchField = [self.searchBar valueForKey:@"searchField"];

        if (searchField) {

            [searchField setBackgroundColor:[UIColor whiteColor]];

            searchField.layer.cornerRadius = 14.0f;

            searchField.layer.borderColor = [UIColor colorWithRed:247/255.0 green:75/255.0 blue:31/255.0 alpha:1].CGColor;

            searchField.layer.borderWidth = 1;

            searchField.layer.masksToBounds = YES;

        }


更改UISearchBar占位符居左

http://www.jianshu.com/p/0787277973d4

电阻抗成像肺功能测试数据分析与直方图生成 本文介绍了基于MATLAB的电阻抗成像(EIT)肺功能测试数据分析方法。研究针对32×32像素的EIT图像序列,通过三步算法处理:首先计算特定时间点与谷值图像的差值,然后分析1秒后峰值与1秒值的差值,最终计算比值矩阵并处理异常值。系统展示了数据预处理、关键时间点检测、比值计算及统计分析的全流程,包括生成概率分布直方图和空间分布图等可视化方法。该分析为无创肺功能评估提供量化指标,可应用于临床呼吸监测和疾病诊断。 阅读详情

相关推荐

【论文精读】Latent Diffusion

Latent Diffusion

weixin_44934783的博客 4476

UiSearchBar圆角设置

有时我们可能会遇到这样的需求:如图搜索框两边是圆形的,当然这样的效果有很多方法来实现,但是个人感觉有点麻烦,今天我们用UISearchBar来实现上面的效果;具体实现思路是我们得到UISearchBar的子视图UITextField来设置其圆角,在系统的UISearchBar中UITextfield是这样的命名的searchField所以我们只要利用KVC得到就可以,具体实现代码如下: UITe

半桶水技术的博客 7517

KEGG数据库与KAAS工具:基因功能注释的实用指南

本文提供了使用KEGG数据库与KAAS工具进行基因功能注释的完整实用指南。详细阐述了如何从准备基因或蛋白序列开始,通过KAAS服务器获取KEGG Orthology(KO)编号,并解读注释结果。文章进一步介绍了如何利用KOBAS工具进行通路富集分析,将定性观察转化为定量洞察,并分享了提高注释准确率、处理大数据集及使用API等避坑技巧与高阶方法,为基因组学、转录组学研究者奠定坚实的数据分析基础。

weixin_29292535的博客 390

iOS自定义UISearchBar,简单、方便、好用

可恶的UI非要搞一个和系统的UISearchBar的不一样的效果,但是系统自带的用实现不了效果,就自能自定义了。把一个UISearchBar放到UINavigationBar上。并且还要有搜索的结果在整个页面上。。。先看看效果图 HZSearchBar自定义searcher,完全模仿系统样式选择遵循协议 CustomsearchResultsUpdater 及时筛选代理同系统的searchResu...

whuizhou的专栏 4274

VXLAN技术详解

VXLAN(虚拟可扩展局域网)是一种Overlay二层虚拟化技术,通过MAC-in-UDP封装在IP网络上构建大规模虚拟二层网络。核心组件包括VTEP(隧道端点)、24位VNI(支持1600万个虚拟网络)和VXLAN网关。相比VLAN,VXLAN具有超大规模扩展、跨三层互联、支持虚拟机无缝迁移等优势,适用于云数据中心多租户隔离、跨数据中心互联等场景。其基于IP路由的封装方式无需改造物理网络,为现代云网络提供了弹性、安全的虚拟化解决方案。

kjkdd的博客 594

基于Simulink的电动汽车电池管理系统热管理优化仿真

电动汽车电池管理系统(Battery Management System, BMS)中的热管理是确保电池性能、安全性和寿命的关键环节。温度过高或过低都会显著影响电池的工作效率和寿命,因此需要对电池组进行精确的热管理。基于MATLAB/Simulink的仿真平台可以用于建模和优化电池热管理系统,包括热分布预测、冷却策略设计以及热平衡控制等。本项目旨在构建一个完整的电动汽车电池热管理优化仿真模型,并通过仿真验证系统的性能。

xiaoheshang_123的博客 461

[iOS]关于UISearchBar, 看这个就够了

UISearchBar一般我们不单独使用他, 在iOS 8之后, 我们更多地是和UISearchController一起使用, 关于UISearchController的一些使用可参考[iOS]系统UISearchController详解, 这里主要是关于UISearchBar的一些设置, 可以单独使用, 也可以对UISearchController中的searchBar 进行设置. 下面这个就是

流火緋瞳的博客 1万+

使用 MATLAB/Simulink 构建一个多时间尺度下的微电网经济运行优化策略模型

本文介绍了基于Simulink的多能互补微电网系统建模方法,重点关注多时间尺度下的经济运行优化策略。内容包括:系统背景与目标、微电网结构设计(光伏、风电、储能、柴油发电机等模块)、多时间尺度能量管理架构(日前优化、日内滚动优化、实时控制)的实现步骤,以及仿真运行与结果分析。教程详细说明了如何在Simulink中调用优化算法,设置仿真参数,并提供了进阶研究方向和资源推荐。该模型为研究微电网的经济运行和智能调度提供了完整的仿真平台解决方案。

amy_mhd的博客 170

UISearchBar

UISearchBar是系统自带的搜索控件 继承于UIView 一.相关属性 seacbar.prompt = @"顶部提示信息"; seacbar.placeholder = @"我是占位文字"; seacbar.text = @"我是搜索的文字"; //右侧按钮相关 四个按钮默认NO //...

江苏小白龙 1212

Hermes Agent 桌面版安装部署完全指南:一步步安装自进化Agent智能体

是由开发的开源自主 AI 智能体(MIT 协议)。它不是绑定在集成编辑器上的编码助手,也不是围绕单一 API 的聊天机器人封装——它是一个越用越强大的自主智能体,拥有独一无二的闭环学习系统特性说明自主技能创建在复杂任务后自动生成可复用的 Skills(技能)技能自我改进使用过程中持续优化已有技能持久化记忆跨会话记住你的项目、偏好和解决方案用户画像建模通过 Honcho 方言式推理,逐步构建对你的深度理解20+ 平台接入。

大模型与Agent智能体 7757

HarmonyOS应用开发者基础认证

B. 自定义组件:可复用的 UI 单元,可组合其它组件。D. 内置组件:ArkTS中默认内置的基本组件和布局组件,开发者可以直接调用,如Column、Text、Divider、Button等。E. 属性方法:用于组件属性的配置,统一通过属性方法进行设置,如fontSize()、width()、height()、color() 等。在Column和Row容器组件中,justifyContent用于设置子组件在主轴方向上的对齐格式,alignItems用于设置子组件在交叉轴方向上的对齐格式。

牛肉胡辣汤 3816

iOS 导航栏添加UISearchBar并自定义背景色、圆角

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:@"尺寸"]; searchBar.delegate = self; searchBar.backgroundColor = [UIColor whiteColor]; searchBar.placeholder = @"请输入景区名称"; se...

xiaoxiaobaibaicai的博客 1111

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Swift 设置UISearchBar圆角以及背景颜色

前言 在APP中经常用到UISearchBar,下面介绍在Swift中如何使用。 一、效果图 二、实现代码 let searchBar = UISearchBar(frame: CGRect(x: 20, y: 100, width:self.view.bounds.width - 40, height: 50)) searchBar.showsCancelButton = false searchBar.delegate = self searchBar

smileKH的博客 2367

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

去除UISearchBar圆角背景

UITextField *searchField; for (UIView *subview in searchBar.subviews){ if ([subview isKindOfClass:[UITextField class]]){ searchField = (UITextField *)subview;

编程路上的野花 1930

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

改 UISearchBar 圆角的小技巧

有些需求非要把 UISearchBar 默认的圆角矩形的圆角改大,顶端改成圆形的。虽然系统没有提供这个 API,不过还是有一个简单方法可以解决。 首先在 UIView 的 category 里加一个方法: UIView+Utils.m - (UIView*)subViewOfClassName:(NSString*)className { for (UIView* subView i

j_AV_a的博客 2065

UISearchBar 自定义处理

首先通过 KVC 获取到内部的 textField, 然后自定制处理 UITextField *searchField = [searchBarvalueForKey:@"searchField"]; if (searchField) { [searchField setBorderStyle:UITextBorderStyleNone]; //p...

weixin_34161029的博客 144

改变UISearchBar的细节问题

UIView *topView = _searchBar.subviews[0];               NSLog(@"%@",topView.subviews);          for (UIView *subView in topView.subviews) {         NSLog(@"%@",subView);    

水清_木秀的博客 434

UISearchBar 的使用

1.UISearchBar 去掉背景、自定义边框(不喜欢自带的的边框阴影可以使用) [[[searchBar subviews] objectAtIndex:0] setAlpha:0]; UITextField *field = (UITextField*)[[searchBar subviews] objectAtIndex:1]; field.background = nil;

snsogblgbl的专栏 734

自定义UISearchBar外观

自定义UISearchBar外观 字数962 阅读2397 评论33 喜欢56 最近,在项目过程中遇到要自定义SearchBar的外观,虽然自己觉得用系统默认的外观就行了,不过UI设计师要求不用系统的默认样式,要跟app主题保持一致。 图1:设计效果图 从上图可以看出,我们要做的UISearchBar要有圆角,边框颜色,取消按钮颜色,背景透明等等。 开

lqk的博客 632

ios开发之--调整UISearchBar的输入框的背景颜色

遍历UISearchBar的子视图,找到输入框坐在的view,添加背景颜色即可。 代码如下: UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 22, kScreenW - 10, 30)]; searchBar.tintColor = [UIColor darkGra...

weixin_33910137的博客 215

搜索条 searcherBar 去掉灰色背景

_searchShopOrGoodBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 310, 24)];     _searchShopOrGoodBar.placeholder = @"请输入商家或商品名称";     [_searchShopOrGoodBar setSearchBarStyle:UISearch

aoliuer117的博客 770

【iOS9】UISearchBar ios9.10设置全局统一样式

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33772645的博客 125

iOS7,修改SearchBar背景色

iOS8,遍历seachBar 得不到textfield了 就意味着之前的方法通通不能用了. mySearchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(5, 28, self.navView.width - 70, 30)]; mySearchBar.delegate = self; mySearchBar.showsC

你猜90516的专栏 688
上一篇: UIAppearance 控件主题修改(navber、tabar、一些UI控件)
下一篇: UISearchController(使用、修改cancel文字)
Gz_Jason_chen
博客等级 码龄11年 49粉丝 141原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值