在我的应用程序中,我尝试添加搜索功能。我有表格视图控制器和自定义顶部栏视图,我在其中显示UISearchBar
。问题是覆盖视图总是位于顶部栏下方一点,并且增加了它们之间的间隙:
In my 表视图控制器.m文件的viewDidLoad:
[super viewDidLoad];
LSDropdownViewController *menuCtrl = (LSDropdownViewController *)[self parentViewController];
menuCtrl.topSearchBar.delegate = self;
[menuCtrl.topSearchBar setBackgroundColor:[UIColor clearColor]];
[menuCtrl.topSearchBar setBackgroundImage:[UIImage imageWithGradientColors]];
[menuCtrl.topSearchBar setTintColor:[UIColor whiteColor]];
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:menuCtrl.topSearchBar contentsController:self];
self.searchController.delegate = self;
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
有任何想法吗?
这是由于iOS7+。因此,要摆脱它,您必须通过将 y 值偏移 20 像素来手动设置搜索栏框架,即 searchBar.frame = CGRectMake(0,20,width,height)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)