有没有办法在不子类化搜索栏的情况下更改 UISearchBar 取消按钮的文本字体和颜色?
最佳答案
当包含在 UISearchBar
中时,您可以通过更改 UIBarButtonItem
的外观来更改取消按钮样式。
例如,
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blueColor],
UITextAttributeTextColor,
[UIColor darkGrayColor],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
nil]
forState:UIControlStateNormal];
关于ios - 修改 UISearchBar 取消按钮字体文字颜色和样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11572372/