robertwijas / UISS

UIAppearance Stylesheets
MIT License
1.23k stars 80 forks source link

Switching between two stylesheets? #12

Closed dogweather closed 11 years ago

dogweather commented 11 years ago

Hi, this library is incredible. It's pretty amazing to see it "just work".

My apps has two modes, and it needs to switch between two look-and-feels. It seems like having two stylesheets makes the most sense. But I'm not sure how to instruct the UI to refresh after switching.

Here's what I'm experimenting with: creating a new UISS instance, and then instructing it to refresh somehow. It's not refreshing, however:

self.uiss = [UISS configureWithURL:...
[self.uiss loadStyleSynchronously];
dogweather commented 11 years ago

Hmm - I'm very new to iOS programming. But with that caveat... should loadStyleAsynchronously be private, because it's already called in the factory method? And then refresh should be public, because it doesn't seem to have any side effects?

robertwijas commented 11 years ago

You may be right about loadStyleAsynchronously. I will think about it. Thanks.

To switch style file try:

self.uiss.style.url = otherFileURL;
[self.uiss reloadStyleAsynchronously];
dogweather commented 11 years ago

Excellent, that works. Thank you.

The UINavigationBar's font in the current view doesn't refresh automatically: this seems to be a known issue with it. I'll probably special case the current view — set layout needed.