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
| class ViewController: ASViewController<ASDisplayNode> { | |
| init() { | |
| super.init(node: ASDisplayNode()) | |
| self.node.backgroundColor = .white | |
| } | |
| required init?(coder aDecoder: NSCoder) { | |
| fatalError("init(coder:) has not been implemented") |
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
| node.layoutSpecBlock = {_,_ in | |
| return ASWrapperLayoutSpec(layoutElement: self.titleNode) | |
| } |
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
| let mainStack = ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 6.0, | |
| justifyContent: .start, | |
| alignItems: .center, | |
| children: [titleNode, subtitleNode]) | |
| return mainStack |
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
| let mainStack = ASStackLayoutSpec(direction: .horizontal, | |
| spacing: 6, justifyContent: .start, | |
| alignItems: .center, | |
| children: [self.titleNode, self.subtitleNode]) | |
| let padding = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15), child: mainStack) | |
| return padding |
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
| let overlayNode = ASDisplayNode() | |
| overlayNode.backgroundColor = UIColor.black.withAlphaComponent(0.3) | |
| let overlay = ASOverlayLayoutSpec(child: mainStack, overlay: self.overlayNode) | |
| return overlay |
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
| let backgroundNode = ASDisplayNodeWithBackgroundColor(UIColor.red) | |
| let foregroundNode = ASDisplayNodeWithBackgroundColor(UIColor.blue) | |
| return ASBackgroundLayoutSpec(child: foregroundNode, background: backgroundNode) |
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
| let center = ASCenterLayoutSpec(centeringOptions: .XY, | |
| sizingOptions: .minimumXY, | |
| child: mainStack) | |
| return center |
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
| let subnode = ASDisplayNodeWithBackgroundColor(UIColor.green, CGSize(width: 100, height: 100.0)) | |
| let ratioSpec = ASRatioLayoutSpec(ratio: 0.5, child: subnode) | |
| return ratioSpec |
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
| let relativeSpec = ASRelativeLayoutSpec(horizontalPosition: .start, | |
| verticalPosition: .start, | |
| sizingOption: [], | |
| child: foregroundNode) |
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
| node.style.layoutPosition = CGPoint(x: 0.0, y: maxConstrainedSize.height / 3.0) | |
| node.style.preferredSize = CGSize(width: maxConstrainedSize.width / 2.0, height: maxConstrainedSize.height / 3.0) | |
| return ASAbsoluteLayoutSpec(children: [node]) |
OlderNewer