【发布时间】:2014-03-05 21:35:21
【问题描述】:
如何更改 SKStoreProductViewController 中的标题颜色和/或条形颜色?
我正在使用外观 API 将导航栏设置为深色,将文本设置为白色。它会更改标题颜色,但不会更改我的 SKStoreProductViewController 中的条形颜色。
【问题讨论】:
标签: ios7 storekit uiappearance
如何更改 SKStoreProductViewController 中的标题颜色和/或条形颜色?
我正在使用外观 API 将导航栏设置为深色,将文本设置为白色。它会更改标题颜色,但不会更改我的 SKStoreProductViewController 中的条形颜色。
【问题讨论】:
标签: ios7 storekit uiappearance
我不认为你可以。至少在 iOS 7 上不行。在 iOS 6 上,您可以使用 UIAppearance 协议,SKSPVC 将采用您在 UINavigationBar 上设置的外观。
如 this thread 所述,SKSPVC 是 remote view controller,因此无法以编程方式访问,这意味着您无法直接(或间接?)设置它的外观。
【讨论】:
执行以下操作以避免 SKStoreProductViewController 接管值为 WHITE 的 tintColor:
#define kCOLOR_NON_WHITE_COLOR [UIColor darkGrayColor]
// CHANGE ALL TINTING BEFORE WE CREATE An INSTANCE OF THIS BROKEN PIECE
[UIWindow appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIView appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UINavigationBar appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIBarButtonItem appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
// NOW CREATE THE THING
SKStoreProductViewController *controller = [[[SKStoreProductViewController alloc] init] autorelease];
这会以定义的颜色 AFAIK 绘制此控制器中的所有 UIBarButtonItems 和 UISegmentedControls,从而使控制器更像您的应用程序设计。
重要提示:只需不要忘记(!!!)在您关闭此控制器后将所有颜色改回,否则您的应用中新创建的视图可能会接管强制着色。
更新:您可能已经发现以下操作外观的方法不起作用:
[UINavigationBar appearanceWhenContainedIn:[SKStoreProductViewController class], nil]
此修复适用于 iOS 6 上的 iOS 7 和 8,您会遇到不同的问题。 =)
【讨论】: