Created
March 29, 2020 00:17
-
-
Save christianselig/83cec27756f9a2a62469a72de013b3c7 to your computer and use it in GitHub Desktop.
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 | |
import AsyncDisplayKit | |
class CommentPreviewViewController: ASViewController<ASDisplayNode> { | |
let rootNode = ASDisplayNode() | |
let textNode = ASTextNode() | |
init() { | |
super.init(node: rootNode) | |
textNode.attributedText = NSAttributedString(string: "Lorem ipsum dolor sit amet.", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15.0)]) | |
rootNode.automaticallyManagesSubnodes = true | |
rootNode.layoutSpecBlock = { (node, constrainedSize) in | |
return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0), child: self.textNode) | |
} | |
} | |
required init?(coder aDecoder: NSCoder) { fatalError("\(#file) does not implement coder.") } | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
let layout = rootNode.layoutThatFits(ASSizeRangeMake(CGSize(width: view.bounds.width, height: CGFloat.greatestFiniteMagnitude))) | |
print(layout.size.height) // Error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment