先週作ったswift-layoutの機能拡張と修正をしました。
https://github.com/grachro/swift-layout
swift-layoutの使用例
//UIViewControllerでの記述例 //UILabelを画面中央に配置 let lblA = UILabel() Layout.regist(lblA, superview: self.view) .horizontalCenterInSuperview() .verticalCenterInSuperview() .backgroundColor(UIColor.whiteColor()) .text("中央") //もう一つのラベルを画面の最下部に配置。x位置は最初のUILabelの中央と同じ let lblB = UILabel() Layout.regist(lblB , superview: self.view) .bottomIsSameSuperview()) .horizontalCenterIsSame(lblA) .text("下")
v0.2修正点
containerをsuperviewに変更
UIKitの世界では、親Viewはsuperviewと表現されているので、引数とメソッド名を修正しました。
Layoutで磨りガラス効果追加
iOS7まではNavigationBarで画面を覆ったり、外部のライブラリを使ったりする必要があったようですが、UIBlurEffectで磨りガラスエフェクトをいれらるようになりました。Layoutクラスでファクトリメソッドを追加しています。
let effect1:UIVisualEffectView = Layout.createExtraLightBlurEffect() let effect2:UIVisualEffectView = Layout.createLightBlurEffect() let effect3:UIVisualEffectView = Layout.createDarkBlurEffect()
内部的には、UIVisualEffectViewとUIBlurEffectを読んでいるだけです。
class func createExtraLightBlurEffect() -> UIVisualEffectView { return UIVisualEffectView(effect: UIBlurEffect(style: .ExtraLight)) }
この方法で作る磨りガラスは厚すぎるようですが、backgroundcolorの透明度をさげても別に薄くはならないようです。