项目作者: werediver

项目描述 :
Reusable and composable UI styles
高级语言: Swift
项目地址: git://github.com/werediver/StyleSheet.git
创建时间: 2016-10-20T14:39:19Z
项目社区:https://github.com/werediver/StyleSheet

开源协议:MIT License

下载


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:

  1. final class TitleLabel: UILabel, TitleFontStyle {}
  2. final class BodyLabel: UILabel, BodyFontStyle, MultilineLabelStyle {}
  3. 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

  1. github "werediver/StyleSheet" ~> 5.0

CacoaPods

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

Note: check the latest available version!

License

MIT