Dynamically set segment button text color

Is it possible to dynamically set color to segment button text color? overriding the default css?
I know from the document we can set our own color with variables.

What if I want to set the color dynamically?
Now the following code works in browser(iOS mode), but on emulator it got overrideen by default value.

noted that i use variable “os” to store the detected user OS and “mycolor” to the color of the theme generated.