All Projects → hboon → Zhi

hboon / Zhi

Licence: bsd-2-clause
Swift Library for Live Reloading Auto Layout Constraints on iOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Zhi

Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+5666.67%)
Mutual labels:  autolayout
Color Picker For Ios
Colorful: iOS color picker built with Swift.
Stars: ✭ 709 (+884.72%)
Mutual labels:  autolayout
Sketchkit
A lightweight auto-layout DSL library for iOS & tvOS.
Stars: ✭ 40 (-44.44%)
Mutual labels:  autolayout
Toolbar
Awesome autolayout Toolbar. Toolbar is a library for iOS. You can easily create chat InputBar.
Stars: ✭ 458 (+536.11%)
Mutual labels:  autolayout
Autoflowlayout
自定义ViewGroup,实现多功能流式布局与网格布局
Stars: ✭ 660 (+816.67%)
Mutual labels:  autolayout
Leego
Declarative, configurable & highly reusable UI development as making Lego bricks.
Stars: ✭ 967 (+1243.06%)
Mutual labels:  autolayout
Autoinch
优雅的iPhone全尺寸/等比例精准适配工具
Stars: ✭ 395 (+448.61%)
Mutual labels:  autolayout
Tagflowlayout
支持多选的自定义标签View,可展开收起,标签样式可自定义。
Stars: ✭ 68 (-5.56%)
Mutual labels:  autolayout
Autolayoutexamplewithmasonry
Different Autolayout examples with Masonry. 用Masonry写的Autolayout案例,持续更新中。详细解答请看tutuge.me
Stars: ✭ 694 (+863.89%)
Mutual labels:  autolayout
Tangramkit
TangramKit is a powerful iOS UI framework implemented by Swift. It integrates the functions with Android layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,LayoutSizeClass to build your App 自动布局 UIView UITableView UICollectionView
Stars: ✭ 984 (+1266.67%)
Mutual labels:  autolayout
Android Ratiolayout
This is a specified proportion to the size of the Layout or View support library, with which you can easily set a fixed ratio of the size of the Layout or View, internal adaptive size calculation, completely abandon the code to calculate the size! If you have any questions in the course or suggestions, please send an e-mail to the following e-mail, thank you!
Stars: ✭ 462 (+541.67%)
Mutual labels:  autolayout
Tablekit
Type-safe declarative table views.
Stars: ✭ 567 (+687.5%)
Mutual labels:  autolayout
Autolayout.js
Apple's Auto Layout and Visual Format Language for javascript (using cassowary constraints)
Stars: ✭ 975 (+1254.17%)
Mutual labels:  autolayout
Easyanchor
⚓️ Declarative, extensible, powerful Auto Layout
Stars: ✭ 432 (+500%)
Mutual labels:  autolayout
Keyboardlayoutguide
⌨️ Manage iOS keyboard with Apple's missing KeyboardLayoutGuide
Stars: ✭ 1,054 (+1363.89%)
Mutual labels:  autolayout
Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (+469.44%)
Mutual labels:  autolayout
Whc autolayoutkit
iOS and Mac OS X platforms currently in use the fastest the simplest development to build the UI layout automatically open source library, strong dynamic layout constraint handling capacity,iOS/Mac OS X平台上目前使用最简单开发构建UI速度最快的自动布局开源库,强悍的动态布局约束处理能力
Stars: ✭ 858 (+1091.67%)
Mutual labels:  autolayout
Screenadaptationkit
🎨iOS rapidScreen Compatible AdapterKit(Deprecate)
Stars: ✭ 70 (-2.78%)
Mutual labels:  autolayout
Framelayoutkit
FrameLayoutKit is a super fast and easy to use autolayout kit
Stars: ✭ 53 (-26.39%)
Mutual labels:  autolayout
Purelayout
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible.
Stars: ✭ 7,548 (+10383.33%)
Mutual labels:  autolayout

Zhi

Swift Library for Live Reloading Auto Layout Constraints on iOS

Adjust Auto Layout constraints and watch your app update immediately without a rebuild + run cycle.

Save precious time.

Demo GIF

Usage

This library allows you to specify your auto layout constraints in separate .styles files. It supports:

  • Live reloading of Auto Layout constraints as you save the .styles files, without a rebuild + run cycle
  • Apple's Visual Format Language: H:[p(==v2)]|
  • Support an equations-based syntax: v1.width = v2.width + 10

In addition, the .styles files also support:

  • Metrics can be specified
  • Colors — rgb(), rgba() or named colors in UIColor, e.g. red
  • Image filenames
  • Button title and label text
  • Font name, size
  • Dynamic type style names, e.g. callout or caption1
  • and more

This means that you can tweak these properties without rebuilding your app during development.

WARNING: Setting of properties like colors are best used in style files only during development. Ship style files that only contains instructions for Auto Layout.

There is an example app included in the repository.

Setup

The library works best if you style based on UIViewController subclasses.

Refer to Installation to install the library

  1. Create a UIViewController subclass

  2. Add a property: lazy var styler = zhiCreateStyler()

  3. Override viewDidLoad() and create a mainView and add it to the view controller's view. You will add all other subviews to mainView instead of the view controller's view directory:

     mainView.frame = view.bounds
     mainView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
     view.addSubview(mainView)
    
  4. Add the following to the end of viewDidLoad() (replacing the value for views and metrics accordingly):

     styler.views = ["celf": mainView, "v1": v1, "v2": v2]
     styler.metrics = ["m": 100, "k": 50]
     styler.keepTranslateAutoResizingMaskForView = mainView
     styler.liveReload(view: view)
     view.setNeedsUpdateConstraints()
    
  5. Override updateViewConstraints():

     override func updateViewConstraints() {
         styler.style(view: mainView)
         super.updateViewConstraints()
     }
    
  6. In your app delegate, add (during development):

    Zhi.Styler.logEnabled = true

  7. Create a directory call Styles and create 1 style file for each view controller. If your view controller called MyViewController, name the file MyViewController.styles

This is enough to get the library to style your view controller.

To get live reload to work, you need to pass in the path of the directory containing your styles to the library. The cleanest way to do this without duplication is to specify it in your Info.plist file.

  1. In Xcode project settings for your target, click Build Settings
  2. Click the + button to add a User-Defined Setting.
  3. Name the setting STYLES_DIRECTORY
  4. Set the value to the Styles/ directory. eg.: $(SRCROOT)/ZhiExample/Styles/
  5. Delete the value for all release builds. (When this value is empty, the library will not attempt to live reload styles). See example.
  6. Open your Info.plist file (or click Info in project settings)
  7. Add a property called STYLES_DIRECTORY
  8. Set the value to: $(STYLES_DIRECTORY). See example.

Styles Files Syntax


Styles files are line-based. Empty lines are ignored

Comments start with a single #

# This is a comment

Metrics start with ##

##m1=80

Visual Format Language:

H:|[v1][v2]-m1-|

Equation-based syntax:

v1.width = v2.width*2

Properties:

v1.backgroundColor = rgb(90, 200, 250)

i.backgroundColor = gray
i.contentMode = scaleAspectFill
i.clipsToBounds = true
i.image = color.jpeg

b.title = Tap Me
b.textStyle = largeTitle

l.fontName = Thonburi
l.fontSize = 30
l.numberOfLines = 0

Quirks & Gotchas

Constraints especially those written in Visual Format Language are passed directly to to Auto Layout, so errors might crash the app like it normally does.

This library is currently only for iOS.

Installation

Zhi is available through CocoaPods.

CocoaPods

In order to install Zhi using CocoaPods, add the following line to your Podfile:

pod "Zhi"

Dependencies

License

BSD 2-clause. See LICENSE file.

More

Zhi is based on my previous library purplish-layout written in RubyMotion. It's also inspired by @twerth's rmq (also in RubyMotion). Some of the parsing code is shamelessly lifted from @marcoarment's CompactConstraint

Questions

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].