Created
September 3, 2018 21:17
-
-
Save d-date/28df56fb11eb72fa2493b4aae57adfd9 to your computer and use it in GitHub Desktop.
Also, we can user function composition to UI implementation #CodePiece #tryswiftnyc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let paragraphStyle = NSMutableParagraphStyle() | |
paragraphStyle.alignment = .center | |
NSMutableParagraphStyle() |> (prop(\.alignment)) { _ in .center } | |
func set<Root, Value>( | |
_ kp: WritableKeyPath<Root, Value>, | |
_ value: Value | |
) | |
-> (Root) -> Root { | |
return (prop(kp)) { _ in value } | |
} | |
NSMutableParagraphStyle() |> set(\.alignment, .center) | |
let autolayoutStyle = set(\UIView.translatesAutoresizingMaskIntoConstraints, true) | |
UIView() |> autolayoutStyle | |
class MyViewController: UIViewController { | |
let subtitleLabel = UILabel() | |
|> set(\.font, .systemFont(ofSize: 17)) | |
>>> set(\.textColor, UIColor.blue) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment