Skip to content

werediver/StyleSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift 4.2 Platforms: iOS, macOS Carthage compatible CocoaPods compatible

StyleSheet

An approach to define reusable and composable UI styles.

Having some base styles defined you can use them like so:

final class TitleLabel: UILabel, TitleFontStyle {}
final class BodyLabel: UILabel, BodyFontStyle, MultilineLabelStyle {}
final class CaptionLabel: UILabel, CaptionFontStyle, MultilineLabelStyle {}

Example screenshot

For a complete usage example see the Example project.

For the implementation details see Style.swift and RootStyle.swift.

Motivation

Why to define the UI style in code?

Defining the UI style in code is good because it gives

  • reproducible,
  • reusable,
  • and composable results.

Why not to use UIAppearance?

Because we can do better. By avoiding the use of the appearance-proxy we can access all properties and methods (not only UI_APPEARANCE_SELECTOR and dynamic), and nested objects!

Supported base classes

Base class UIAppearance StyleSheet Notes
NSView
UIView
UIBarItem See the issue #1

Installation

Carthage

github "werediver/StyleSheet" ~> 5.0

CacoaPods

pod 'StyleSheet', :git => 'https://github.com/werediver/StyleSheet.git', :tag => 'v5.0.0'

Note: check the latest available version!

License

MIT