RubyMotion RMQ default global styles

142 Views Asked by At

I'd like have default styles for UIViews.

Let's say that I want to have ALL UILabel with backgroundColor of color.light_gray.
Moreover I want to style my custom UIViews, e.g. for EVERY AttributedUILabel I want to have kerning value set to 2.

How to resolve that in RMQ?

1

There are 1 best solutions below

1
On BEST ANSWER

In your RMQ application, you should have an ApplicationStylesheet class from which all your other stylesheets should inherit.

You could add a default_label method in this ApplicationStylesheet:

def default_label(st)
  st.background_color = color.light_gray
end

To apply the style you would have to use it when you append your label

rmq.append UILabel, :default_label

Same goes for your AttributeUILabel, create a method in your ApplicationStylesheet and use the style when you append it to the view.

I suggest you go back to the RMQ stylesheets documentation, it shows everything you need to know about styling.