0

I am new into objective c. In current project, I always outlet each button, text field to respective Controller, and then style it.

Is there any same approach like CSS in globally set the UI's properties/style?

For example, in CSS we can do like following code

.button_global_1{
    border-radius: 8px;
}

//in html
<button class="button_global_1"></button>
<button class="button_global_1"></button>
//2 buttons implements the same style. saving time.

Is there any such approach we can use in objective c? By outletting each UI components to each controller and then style it really consumes lots of time. And I started to find what is the best implementation to manage the UI's components.

Thanks!

Alvin
  • 529
  • 1
  • 8
  • 19

1 Answers1

0

The only thing that comes close to what you describe is the UIAppearance protocol. It doesn't support your example but you can do other stuff like:

[[UIButton appearance] setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

You can also create a UIButton subclass create a property for the corner radius and mark it with UI_APPEARANCE_SELECTOR. That way it is accessible through the UIAppearance protocol.

Aris
  • 1,529
  • 9
  • 17