8vi*_*ius 7 input uiwebview uisegmentedcontrol ios uiappearance
我的应用程序中有一个UIWebView,问题是我有一个UIAppearance来修改分段控件的外观,因此它修改了UIWebView文本字段的输入附件视图中的分段控件,我希望它看起来不错,或者不试图修改它.这是它目前的样子:

我只是通过使用[UIAppearance appearanceWhenContainedIn:]而不是[UIAppearance appearance]来解决这个问题.
通过向选择器发送包含您要自定义的元素的所有自定义ViewController类的nil-terminated列表来使用它.而不是
[[UISegmentedControl appearance] setBackgroundImage:buttonBackgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
使用
[[UISegmentedControl appearanceWhenContainedIn:[MyViewController class], [MyOtherViewController class], nil] setBackgroundImage:buttonBackgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
您不需要列出所有ViewControllers,只需列出您的顶级ViewControllers.这也使得以下技巧成为可能:创建UIViewController的'empty'子类CustomizedViewController,除了作为子类之外什么都不做 - 然后从你的代码中继承子类而不是UIViewController(基本上用'CustomizedViewController'替换'UIViewController'的所有出现' - 除了CustomizedViewController实际上将UIViewController声明为其超类的地方.
然后用
[[UISegmentedControl appearanceWhenContainedIn:[CustomizedViewController class], nil] setBackgroundImage:buttonBackgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1882 次 |
| 最近记录: |