OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在ios的标签栏 Controller 中添加搜索栏? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:49
标题: ios - 如何在ios的标签栏 Controller 中添加搜索栏?

我正在做一个项目,我必须在顶部的标签栏 Controller 上使用搜索栏。我尝试了很多代码但没有工作我正在分享我的代码。请帮我解决这个问题。

UISearchBar *search = [[UISearchBar alloc] init];
    search.frame = CGRectMake(5 ,5, 300,45);
    search.delegate = self;
    search.showsBookmarkButton = NO;
    search.placeholder = @"Search/Select a Creative Service";
    search.barTintColor = [UIColor blackColor];



Best Answer-推荐答案


将搜索栏设置为标题 View :

self.navigationItem.titleView = search;

关于ios - 如何在ios的标签栏 Controller 中添加搜索栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32562604/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4