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 | |
| @propertyWrapper | |
| struct HeaderStyle { | |
| var wrappedValue: UILabel | |
| init(_ label: UILabel = .init()) { | |
| label.numberOfLines = 0 | |
| label.font = UIFont(name: "Helvetica Neue", size: 32) | |
| label.textColor = UIColor(red: 0.16, green: 0.16, blue: 0.16, alpha: 1.00) |
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 SnapKit | |
| import UIKit | |
| class ViewControllerLayout: Layout { | |
| lazy var square = UIView(backgroundColor: .red) | |
| lazy var circle = UIView( | |
| backgroundColor: .blue.withAlphaComponent(0.9), | |
| cornerRadius: 50 | |
| ) |
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 | |
| class Layout: UIView { | |
| required init() { | |
| super.init(frame: .zero) | |
| backgroundColor = .white | |
| layer.masksToBounds = true | |
| } |
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 | |
| extension UIView { | |
| convenience init(backgroundColor: UIColor) { | |
| self.init() | |
| self.backgroundColor = backgroundColor | |
| } | |
| convenience init(backgroundColor: UIColor, cornerRadius: CGFloat) { |
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 SnapKit | |
| import UIKit | |
| extension ConstraintMaker { | |
| func square(view: UIView) { | |
| width.equalTo(view.snp.height) | |
| } | |
| func square(size: CGFloat) { | |
| width.equalTo(size) |
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 SnapKit | |
| import UIKit | |
| extension ConstraintMaker { | |
| func fillHorizontally(margin: CGFloat = 0) { | |
| leading.equalToSuperview().offset(margin) | |
| trailing.equalToSuperview().offset(-margin) | |
| } | |
| func fillVertically(margin: CGFloat = 0) { |
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 SnapKit | |
| import UIKit | |
| extension UIView { | |
| func addSubview(_ view: UIView, closure: (ConstraintMaker) -> Void) { | |
| addSubview(view) | |
| view.snp.makeConstraints(closure) | |
| } | |
| } |
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 SnapKit | |
| import UIKit | |
| class ViewControllerLayout: UIView { | |
| lazy var square: UIView = { | |
| let view = UIView() | |
| view.backgroundColor = .red | |
| return view | |
| }() |
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
| enum Access { | |
| case create | |
| case read | |
| case write | |
| case delete | |
| } | |
| protocol PFile { | |
| func open(access: Access) | |
| func close() |
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 Foundation | |
| let b1 = Bool("1") // nil | |
| let b0 = Bool("0") // nil | |
| let bYes = Bool("YES") // nil | |
| let bNo = Bool("NO") // nil | |
| let bTrue = Bool("true") // true | |
| let bFalse = Bool("false") // false | |
| print(true) // "true\n" |