SnapKitten — Swift library for linear layout

let userProfile : UIView = 
Kitten.horizontal().from()
.add(imageView).size(40)
.add(label).itemOffset(10)
.build()
let userProfile : UIView = Kitten.horizontal().from().defaultAlignment(.start)
.add(iv).size(40)
.add(lblA).itemOffset(10)
.build()
userProfile.backgroundColor = UIColor.orangelet bottomMenu =
Kitten.horizontal().from()
.weightMode(true)
.add(ivA).height(60)
.add(ivB).height(60)
.add(ivC).height(60)
.build()
let scrollView = UIScrollView()Kitten.create(.vertical).from(viewController).isAlignDirectionEnd(true).add(userProfile).alignSideStart()
.add(scrollView).fillParent()
.add(bottomMenu)
.build()
pod "SnapKitten"
import UIKit
import SnapKitten
import PlaygroundSupport

let virtualView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 100))
virtualView.backgroundColor = UIColor.gray
PlaygroundPage.current.liveView = virtualView

let iv = UIImageView()
iv.backgroundColor = UIColor.red
let lblA = UILabel()
lblA.text = "Hello World"
lblA.backgroundColor = UIColor.blue

let simpleComponent = Kitten.horizontal().from()
.add(iv).size(40)
.add(lblA).itemOffset(10)
.build()
simpleComponent.backgroundColor = UIColor.green

Kitten.create(.vertical).from(virtualView)
.add(simpleComponent).align(.start)
.build()
//some java code example
Kitten.create(KittenOrientation.vertical) .from(mainView).isAlignDirectionEnd(true) .add(temp).align(KittenAlignment.parent) .add(imageView)
.add(textViewA).build();

Thank you for your reading!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store