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
?
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.
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];
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