Is it possible to make one style for UIButton (or any UI component) and set that style for selected buttons from Xcode Interface (storyboard)?
Like in web-development you create one css class and use in any elements.
Is it possible to make one style for UIButton (or any UI component) and set that style for selected buttons from Xcode Interface (storyboard)?
Like in web-development you create one css class and use in any elements.
2
Answers
It is possible to style all components of the same type by using UIAppearance. When it comes to styling individual components it’s best to declare some common styling functions and then apply them on specific components. You could also create subclasses and style them individually.
Yes, this possible. You need to make a custom button class, which is a subclass of
UIButton. For example, the code below sets the background color
Then in Xcode Interface (storyboard), for every button, you wish to use this style.
Set the Custom Class in the identity inspector.