导航栏中的UISearchBar [英] UISearchBar in navigationbar

查看:120
本文介绍了导航栏中的UISearchBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在NavigationBar中显示UISearchBar?

How can I show a UISearchBar in the NavigationBar?

我无法弄清楚如何做到这一点。

I can't figure out how to do this.

非常感谢您的帮助。

推荐答案

将searchBar放入navigationBar的中心:

To put searchBar into the center of navigationBar:

self.navigationItem.titleView = self.searchBarTop;

将searchBar放在navigationBar的左/右侧:

To put searchBar to the left/right side of navigationBar:

UIBarButtonItem *searchBarItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];
self.navigationItem.rightBarButtonItem = searchBarItem;

这篇关于导航栏中的UISearchBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆