相关疑难解决方法(0)

appearanceWainContainedIn在Swift中

我正在尝试将我的应用程序转换为Swift语言.

我有这行代码:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
                     setTitleTextAttributes:textDictionary
                                   forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

如何将其转换为Swift?

Apple的文档中,没有这样的方法.

ios uiappearance swift

124
推荐指数
4
解决办法
4万
查看次数

更改UISearchBar iOS 7的字体大小和字体样式

如何在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中崩溃了

objective-c uitextfield uisearchbar ios7

25
推荐指数
3
解决办法
2万
查看次数

更改UISearchBar textColor无法正常工作

我正在使用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

但这不起作用.对此我需要帮助.

google-maps uisearchbar google-places-api uiappearance

3
推荐指数
2
解决办法
1453
查看次数

为什么不能在iOS11中设置搜索栏的文本颜色?

我在较早的版本中使用它来在我的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)

iphone objective-c ios ios11

3
推荐指数
2
解决办法
2854
查看次数

更改 UISearchBar 的文本颜色和边框颜色

我有一个UISearchBar, 搜索样式为“最小”,我想更改文本颜色并使用1px width. 我正在尝试,tintcolor但我什么也没得到

谢谢你。

objective-c uisearchbar ios

2
推荐指数
1
解决办法
2499
查看次数