gpt4 book ai didi

iphone - 在为其 UIAppearance 设置样式时如何定位特定的 UIView?

转载 作者:可可西里 更新时间:2023-11-01 06:23:42 25 4
gpt4 key购买 nike

我在 iOS 5 中使用 UIAppearance 设置全局样式.这是一个例子:

[[UIbarButtonItem appearance]
setTtitletextAttributes:someStyle
forState:UIControlStateNormal
];

在大多数情况下看起来不错:

enter image description here

但有些情况下全局样式看起来很难看,比如在电影播放器​​中。

enter image description here

对于电影播放器​​,我更希望有默认的蓝色按钮。那么我如何只针对后退按钮的外观而不是完成按钮的外观呢?我在定位普通表格单元格和分组表格单元格时遇到类似问题。

最佳答案

您需要使用 UINavigationBar 的自定义子类。我们称它为 MyNavigationBar。然后你可以这样做:

[[UIBarButtonItem appearanceWhenContainedIn:[MyNavigationBar class], nil]
setTintColor:[UIColor redColor]];

它只会影响导航栏中的按钮,不会影响 MPMoviePlayerController 的导航栏。

当然,问题是 UINavigationController 总是使用基本的 UINavigationBar... 如果您在代码中创建它。但是,如果您在 nib 中创建它,则可以单击其导航栏(在 nib 的文档大纲中)并在身份检查器中更改栏的类。

关于iphone - 在为其 UIAppearance 设置样式时如何定位特定的 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985724/

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