Can I change ios/android theme dynamically?


#1

Let say I have an iphone, the app will start with the ios theme by default.

If I want to switch to the “md” theme, what would be the function to do it, if any? I did not find anything on “Config”

Thanks


Change theme after installing the app on the device
#2

It’s actually documented, but you have to do a little research. If you take a look over here: http://ionicframework.com/docs/v2/theming/platform-specific-styles/ it states that ‘You can change the mode that gets assigned in the configuration of your app. Therefore, if you wanted the Material Design md mode on iOS, you could do it.’

So. if you look at the documented API, we see a config possibility. It has exactly what you are asking for.

Try this one:
@App({
template: <ion-nav [root]="root"></ion-nav>
config: {
mode: ‘md’
}
})


#3

Yeah, I know that one, but this is only when the app starts. It will take that config info.

What about after the app started. Is there a way to load a different css file?


#4

Why would you want to change css styles after startup? You want to change the default style after everything is rendered?


#5

Only if possible. Probably not, but I had to ask. :slight_smile:

I will just re-run the app once the change is done


#6

This might do what you need: http://ionicframework.com/docs/v2/api/config/Config/. It seems like you can change app-wide styling at runtime.


#7

where did you see that exactly? I know you can change it from the browser, but what about on the phone?


#8

I’m only going off the example since it has a button to reload the configuration. I’ve never used it so I can’t help you beyond that, sorry.