0

Let's say I want to use a different font, different font sizes, and a different color scheme for my app, and let's say I want to use Interface Builder.

I want to be able to style all these in one place, instead of say going to each label on Interface Builder and changing its font, color, etc.

What is the most common way to achieve this?

I know you can set these things up in code, but then I can't see the changes in Interface Builder?

Having to change these all one by one is a maintenance nightmare, and I can't seem to find any easy way to create custom styles directly in Interface Builder.

The only way I can think of is subclassing each of these views, such as label, button, etc., creating XIBs for each, and making them @IBDesignable.

Is this the way to go? It feels like it's just an unnecessary amount of work, for something simple.

Sharath
  • 275
  • 1
  • 18

1 Answers1

0

If you want to change simple properties of UIKit controls, you can use UIAppearance.

With UIAppearance, You can change appearance like, TextColor, Backgorund color, Tintcolor etc for almost all UIKit Controls.

for ex: Change UIbutton's title Color appearance:

UIButton.Appearance.SetTitleColor (UIColor.Brown, UIControlState.Normal);

Change UILable's Background Color appearance

 UILabel.Appearance.BackgroundColor = UIColor.Blue;

Well, If you want to customise it to next level- Only way is by long process like Subclassing controls as you explained in your question

PlusInfosys
  • 3,416
  • 1
  • 19
  • 33
  • I don't want all the UIButton or UILabel to have the same styling .. for example some label can be title of a page while other lablel is just a text ... I might want a label that shows as error to appear in red color and warning to appear as orange color. – Sharath Apr 10 '17 at 10:14
  • and these changes can be seen only if the app is running not in storyboard – Sharath Apr 10 '17 at 10:15
  • Basically I should be able to define the properties of label based on some grouping – Sharath Apr 10 '17 at 10:16