TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Meniny.
Lollipop
is a syntactic sugar for Auto Layout
.
Lollipop
是一块 Auto Layout
的语法糖。
You are welcome to fork and submit pull requests.
Lollipop
is open-sourced software, licensed under the MIT
license.
center(in:offset:priority:active:)
centerX(equalTo:offset:priority:active:)
centerX(equalTo:offset:priority:active:)
centerY(equalTo:offset:priority:active:)
centerY(equalTo:offset:priority:active:)
edges(equalTo:insets:priority:active:)
edges(top:leading:bottom:trailing:insets:priority:active:)
size(equalTo:priority:active:)
size(equalTo:by:priority:active:)
origin(equalTo:offset:priority:active:)
width(_:to:priority:active:)
width(_:to:multiplier:offset:priority:active:)
width(_:to:multiplier:offset:priority:active:)
width(from:to:priority:active:)
height(_:to:priority:active:)
height(_:to:multiplier:offset:priority:active:)
height(_:to:multiplier:offset:priority:active:)
height(from:to:priority:active:)
leading(_:to:offset:priority:active:)
leading(_:to:offset:priority:active:)
left(_:to:offset:priority:active:)
left(_:to:offset:priority:active:)
trailing(_:to:offset:priority:active:)
trailing(_:to:offset:priority:active:)
right(_:to:offset:priority:active:)
right(_:to:offset:priority:active:)
top(_:to:offset:priority:active:)
top(_:to:offset:priority:active:)
bottom(_:to:offset:priority:active:)
bottom(_:to:offset:priority:active:)
import Foundation
#if os(OSX)
import AppKit
public typealias Color = NSColor
public typealias Controller = NSViewController
#else
import UIKit
public typealias Color = UIColor
public typealias Controller = UIViewController
#endif
import Lollipop
public extension Controller {
public func addItems(to v: ALView) {
let max = 10
for i in 1...max {
let value: CGFloat = 1 - CGFloat(i) / CGFloat(max)
let item = ALView()
item.setColor(Color(red: value, green: value, blue: value, alpha: 1.0))
v.addSubview(item)
item.width(.equal, to: v, multiplier: value)
item.height(.equal, to: item.widthAnchor)
item.center(in: v)
}
}
}
class ViewController: Controller {
override func viewDidLoad() {
super.viewDidLoad()
addItems(to: self.view)
}
}