Skip to main content
added 555 characters in body
Source Link

The Navigation Bar style in question doesn't come from GoogleCast SDK (at least for version 4.6.1 dynamic on iOS 15) but from your own app's appearance. A way to change the background and title text color of the Navigation Bar (on GoogleCast SDK View Controllers, but your own app's as well) is to add

UINavigationBar.appearance().backgroundColor = UIColor.darkGray
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

in your AppDelegate's didFinishLaunchingWithOptions function. But, no matter what tint color field I try setting for either UINavigationBar or UIBarButtonItem appearance, I can't get the Cancel button text color to change. I noticed that behavior in my app as well, only the Navigation Bar Buttons that have the tint set as Default in the Storyboard are affected by this global change, specifically by setting

UIBarButtonItem.appearance().tintColor = UIColor.yellow

If on the other hand you set a color in the Storyboard yourself, it will not be changed by the line of code above. This conclusion leads me to believe that is the way the Device Chooser View Controller was created, with a tint color set explicitly.

But, I see in one of the comments to the main question that someone was able to change the Cancel button color (as seen in the screenshot as well), so if anyone can share that piece of code it would be extremely appreciated.

Thanks!

EDIT

And of course only after posting this I tried pasting the entire code snippet from Reimond Hill and it worked in changing the Cancel button color, specifically this

GCKUIStyle.sharedInstance().castViews.deviceControl.connectionController.navigation.buttonTextColor = navigationtintColor

The reason why I thought this wouldn't work first time around is the fact that we are setting the navigation property of the Connection Controller, not the Device Controller (which doesn't even have this property). So I hope this will help someone else not waste time on this like I did.

The Navigation Bar style in question doesn't come from GoogleCast SDK (at least for version 4.6.1 dynamic on iOS 15) but from your own app's appearance. A way to change the background and title text color of the Navigation Bar (on GoogleCast SDK View Controllers, but your own app's as well) is to add

UINavigationBar.appearance().backgroundColor = UIColor.darkGray
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

in your AppDelegate's didFinishLaunchingWithOptions function. But, no matter what tint color field I try setting for either UINavigationBar or UIBarButtonItem appearance, I can't get the Cancel button text color to change. I noticed that behavior in my app as well, only the Navigation Bar Buttons that have the tint set as Default in the Storyboard are affected by this global change, specifically by setting

UIBarButtonItem.appearance().tintColor = UIColor.yellow

If on the other hand you set a color in the Storyboard yourself, it will not be changed by the line of code above. This conclusion leads me to believe that is the way the Device Chooser View Controller was created, with a tint color set explicitly.

But, I see in one of the comments to the main question that someone was able to change the Cancel button color (as seen in the screenshot as well), so if anyone can share that piece of code it would be extremely appreciated.

Thanks!

The Navigation Bar style in question doesn't come from GoogleCast SDK (at least for version 4.6.1 dynamic on iOS 15) but from your own app's appearance. A way to change the background and title text color of the Navigation Bar (on GoogleCast SDK View Controllers, but your own app's as well) is to add

UINavigationBar.appearance().backgroundColor = UIColor.darkGray
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

in your AppDelegate's didFinishLaunchingWithOptions function. But, no matter what tint color field I try setting for either UINavigationBar or UIBarButtonItem appearance, I can't get the Cancel button text color to change. I noticed that behavior in my app as well, only the Navigation Bar Buttons that have the tint set as Default in the Storyboard are affected by this global change, specifically by setting

UIBarButtonItem.appearance().tintColor = UIColor.yellow

If on the other hand you set a color in the Storyboard yourself, it will not be changed by the line of code above. This conclusion leads me to believe that is the way the Device Chooser View Controller was created, with a tint color set explicitly.

But, I see in one of the comments to the main question that someone was able to change the Cancel button color (as seen in the screenshot as well), so if anyone can share that piece of code it would be extremely appreciated.

Thanks!

EDIT

And of course only after posting this I tried pasting the entire code snippet from Reimond Hill and it worked in changing the Cancel button color, specifically this

GCKUIStyle.sharedInstance().castViews.deviceControl.connectionController.navigation.buttonTextColor = navigationtintColor

The reason why I thought this wouldn't work first time around is the fact that we are setting the navigation property of the Connection Controller, not the Device Controller (which doesn't even have this property). So I hope this will help someone else not waste time on this like I did.

Source Link

The Navigation Bar style in question doesn't come from GoogleCast SDK (at least for version 4.6.1 dynamic on iOS 15) but from your own app's appearance. A way to change the background and title text color of the Navigation Bar (on GoogleCast SDK View Controllers, but your own app's as well) is to add

UINavigationBar.appearance().backgroundColor = UIColor.darkGray
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

in your AppDelegate's didFinishLaunchingWithOptions function. But, no matter what tint color field I try setting for either UINavigationBar or UIBarButtonItem appearance, I can't get the Cancel button text color to change. I noticed that behavior in my app as well, only the Navigation Bar Buttons that have the tint set as Default in the Storyboard are affected by this global change, specifically by setting

UIBarButtonItem.appearance().tintColor = UIColor.yellow

If on the other hand you set a color in the Storyboard yourself, it will not be changed by the line of code above. This conclusion leads me to believe that is the way the Device Chooser View Controller was created, with a tint color set explicitly.

But, I see in one of the comments to the main question that someone was able to change the Cancel button color (as seen in the screenshot as well), so if anyone can share that piece of code it would be extremely appreciated.

Thanks!