Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS equivalent to a stylesheet?

Tags:

ios

styles

  • HTML has CSS styles e.g. class="styleName"
  • Windows8/XAML has static style resources e.g. Style="{StaticResource styleName}"
  • Android has style tags e.g. style="@style/styleName"
  • iOS has ???

I'm using the interface builder for iOS in Xcode, how do I start to build up a style set or equivalent to styles? I want the ability to apply 'styles' to elements and then if I update that style's properties, the changes are applied to all elements that have been given that style. Is this possible in iOS development? Can someone please enlighten me as to how this is achieved or the equivalent please in iOS development. I'm very new to iOS development as you can see.

Is it more related to skins or themes? I don't have a clue.

like image 793
Dave Haigh Avatar asked Aug 30 '13 08:08

Dave Haigh


3 Answers

  • There's Appearence. You often see this being used for colours, but it also does fonts, sizes, and a few other things. Here's another good article from a well known source.

  • Additionally, a common way to style/'skin' is by having different sets of background/button/... images.

  • You can also style by parameterizing drawing code. Have a look at the fabulous tool PaintCode.

  • Then, some companies do (part of the) UI in HTML/JavaScript.

  • Another thing to mention in this context is iOS' Auto Layout

like image 77
meaning-matters Avatar answered Oct 19 '22 01:10

meaning-matters


You can do this with MarkupKit. See the section in the README entitled "Template Properties".

like image 37
Greg Brown Avatar answered Oct 19 '22 00:10

Greg Brown


There isn't a good API in UIKit for this, unfortunately, but there are third party solutions with various tradeoffs.

I created a library that uses style classes, like CSS, which you can define in code, or inside a JSON file, and then apply to views in your app. As an extra benefit, the library uses @IBDesignable to live render your styles inside Storyboards without having to compile the app first to see the results.

https://github.com/daniel-hall/Stylish

like image 1
Daniel Hall Avatar answered Oct 19 '22 00:10

Daniel Hall