大佬教程收集整理的这篇文章主要介绍了iphone – 目标c中UINavigationBar右侧的UISearchBar,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在导航栏中添加搜索栏时,它位于navigationBar的中间位置.在中间,相反,我想显示一个特定的图像.
我怎样才能做到这一点?
这是我的代码片段,
[self.navigationController.navigationBar setTintColor:[[UIColor alloc]initWithRed:150.0 / 255 green:22.0 / 255 blue:22.0 / 255 alpha:0.0]]; UIImage *image = [UIImage imagenamed:@"logo(1).png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [self.navigationItem settitleView:imageView]; self.navigationItem.titleView = sBar; [titleView release];
使用上面的代码,我只能在模拟器中看到searchBar(位于中间).
UISearchBar *searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0,100,40)] autorelease]; searchBar.BACkgroundImage = [[[UIImage alloc] init] autorelease]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:searchBar] autorelease];
您可以随时更改框架.请记住,BACkgroundImage属性仅在iOS 5中可用.您应该搜索替代选项以摆脱iOS 4.x的背景
如果这对您有用,请告诉我.
以上是大佬教程为你收集整理的iphone – 目标c中UINavigationBar右侧的UISearchBar全部内容,希望文章能够帮你解决iphone – 目标c中UINavigationBar右侧的UISearchBar所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。