gpt4 book ai didi

objective-c - 如何将 UISerachBar 添加到 UIToolBar?

转载 作者:行者123 更新时间:2023-12-04 22:00:18 25 4
gpt4 key购买 nike

我现在尝试这样的事情:

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIViewController *searchBarContainer = [[UIViewController alloc] initWithFrame:searchBar.frame];
[searchBarContainer addSubview:searchBar];

NSArray* buttons = [NSArray arrayWithObjects:fixed, searchBarContainer, nil];

[detailToolbar setItems:buttons animated:NO];

最佳答案

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIBarButtonItem * searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];

UIToolbar * searchToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,0+20,[self view].bounds.size.width,32)];

[searchToolbar setItems:[NSArray arrayWithObjects:searchBarButtonItem,homeButtonItem, nil] animated:YES];

关于objective-c - 如何将 UISerachBar 添加到 UIToolBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5903394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com