tombenner / nui

Style iOS apps with a stylesheet, similar to CSS
MIT License
3.76k stars 461 forks source link

override styles when initialize UI Element style properties ? #132

Open michelson opened 11 years ago

michelson commented 11 years ago

Hello , i´ve been playing with NUI in the last hours , and has been great so far !!

i only have a question regarding the override of styles when set style properties directly on the object like for example, in my .nss i have the following:

View { background-color: @primaryBackgroundColor; }

but i need to initialize some UIView with arbitrary colors from some data source, so if I do something like (ruby code) this:

 @blue_view = UIView.alloc.initWithFrame(CGRectMake(0, 0, 10,10))
 @blue_view.backgroundColor = UIColor.blueColor

the color don't get override and always get the nss style

this is a normal behavior ? how can i override it ?

thanks

jjaffeux commented 11 years ago

+1

jjaffeux commented 11 years ago

@michelson the only workaround I have found atm is creating two nss classes :

MainView {
    background-color: #f2e8de;
}

OtherView {
    background-color: #333;
}

and then using self.view.nuiClass = "MainView"

Not perfect as having a default saves a lot of code.