How to style GCKUIMiniMediaControlsViewController in iOS?

牧云@^-^@ 提交于 2020-01-04 09:22:01

问题


I'm upgrading current Cast SDK to V3 and want to use build-in UI components and remove deprecated functions.

Currently, the GCKUIMiniMediaControlsViewController has a white/light theme but I'd like to change it to a darker theme. However, I couldn't find any function/propert/protocol that I can use to change the style. The document Add Advanced Cast v3 Features to your iOS App says:

The Cast framework widgets supports the Apple UIAppearance Protocol in UIKit to change the appearance of the widgets across your app, such as the position or border of a button. Use this protocol to style the Cast framework widgets to match an existing apps styling.

This makes me feel like I can change the appearance but I'm not quite sure what does The Cast framework widgets supports the Apple UIAppearance Protocol in UIKit mean :(

I also find a previous question which also related to Cast SDK's UI component. How can I get access to Introductory Overlay?

Can anyone help me how to change the style for GCKUIMiniMediaControlsViewController?


回答1:


You need to follow Apple's instructions on using the UIAppearance protocol. Note that any changes you make to the styling will happen across the entire app.




回答2:


Cast SDK v3 for iOS introduced GCKUIStyle. This makes styling of all cast views very easy (which includes mini controller, expanded controller, etc). As it contains pretty much all properties for customization.

For GCKUIMiniMediaControlsViewController specifically

GCKUIStyle *castStyle = [GCKUIStyle sharedInstance];

// customize Mini Controller
GCKUIStyleAttributesMiniController *miniCtrlStyle = [[[castStyle castViews] mediaControl] miniController];
[miniCtrlStyle setBackgroundColor:backColor];
[miniCtrlStyle setIconTintColor:[UIColor whiteColor]];
[miniCtrlStyle setHeadingTextColor:[UIColor whiteColor]];

[castStyle applyStyle];



回答3:


https://developer.apple.com/reference/uikit/uiappearance

For example if you want to change the background color of every UILabel that is contained in GCKUIExpandedMediaControlsViewController.

ex in Swift:

UILabel.appearance(whenContainedInInstancesOf:[GCKUIExpandedMediaControlsViewController.self]).backgroundColor = URColors.URStrawberryRed



来源:https://stackoverflow.com/questions/38905943/how-to-style-gckuiminimediacontrolsviewcontroller-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!