Lollipop
是 Auto Layout
的一块语法糖。
Lollipop
是一块 Auto Layout
的语法糖。
欢迎您fork并提交pull requests。
Lollipop
是开源软件,受MIT许可协议保护。
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)
}
}