我正在尝试将我的应用程序转换为Swift语言.
我有这行代码:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setTitleTextAttributes:textDictionary
forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
如何将其转换为Swift?
在Apple的文档中,没有这样的方法.
如何在iOS 7中更改UISearchBar的字体大小和字体样式?
UITextField *textField = [[searchBar subviews] objectAtIndex:1];
[textField setFont:[UIFont fontWithName:@"Helvetica" size:20]];
Run Code Online (Sandbox Code Playgroud)
在iOS 6中工作,但它在iOS 7中崩溃了
我正在使用google places API for autoComplete小部件.我正在使用swift在ios 9+中显示全屏控制.我正在添加文档中给出的完整控件.
我添加了文档中显示的代码.现在我想将searchBar文本颜色更改为whiteColor.
所以我尝试了这个
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).textColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
但我没有得到理想的行为.以下是截图
这已在Docs中给出
https://developers.google.com/places/ios-api/autocomplete#use_a_table_data_source
但这不起作用.对此我需要帮助.
我在较早的版本中使用它来在我的searchBar中获取文本字段...
UITextField *searchField = [self.navigationItem.searchController.searchBar valueForKey:@"_searchField"];
Run Code Online (Sandbox Code Playgroud)
在iOS11中,它仍然可以使用,我可以更改文本(字体,甚至colortcolor),但是我无法设置文本颜色,请教我。
UISearchController *mySearchController = [[UISearchController alloc] initWithSearchResultsController:nil];
mySearchController.searchResultsUpdater = self;
self.navigationItem.searchController = mySearchController;
Run Code Online (Sandbox Code Playgroud)
// mySearchController.hidesNavigationBarDuringPresentation = false; self.navigationItem.hidesSearchBarWhenScrolling = NO;
self.tableView.refreshControl = [[UIRefreshControl alloc] init];
[self.tableView.refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
self.navigationItem.title = @"xxxx";
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"reload" style:UIBarButtonItemStylePlain target:self action:@selector(refresh)];
self.navigationItem.rightBarButtonItem = item;
UITextField *txfSearchField = [self.navigationItem.searchController.searchBar valueForKey:@"_searchField"];
txfSearchField.tintColor=[UIColor blueColor];
//this code is no use
txfSearchField.textColor=[UIColor yellowColor];
txfSearchField.backgroundColor=[UIColor whiteColor];
UIView *backgroundview= [[txfSearchField subviews]firstObject ];
backgroundview.backgroundColor=[UIColor whiteColor];
backgroundview.layer.cornerRadius = 8; …Run Code Online (Sandbox Code Playgroud) 我有一个UISearchBar, 搜索样式为“最小”,我想更改文本颜色并使用1px width. 我正在尝试,tintcolor但我什么也没得到
谢谢你。
ios ×3
objective-c ×3
uisearchbar ×3
uiappearance ×2
google-maps ×1
ios11 ×1
ios7 ×1
iphone ×1
swift ×1
uitextfield ×1