我不明白为什么不显示文本
导入UIKit 导入AsyncDisplayKit
ViewController类:ASViewController {
python MyProgram.py
}
init() {
super.init(node: ASDisplayNode())
let text = ASTextNode()
let attrs = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue", size: 12.0)!]
let string = NSAttributedString(string: "Hello World!", attributes: attrs)
text.attributedText = string
self.node.addSubnode(text)
}
required init?(coder aDecoder: NSCoder) {
super.init(node: ASDisplayNode.init())
}
答案 0 :(得分:0)
import UIKit
import AsyncDisplayKit
class ViewController: ASViewController<ASDisplayNode> {
init() {
super.init(node: LayoutExampleNode())
}
required init?(coder aDecoder: NSCoder) {
super.init(node: ASDisplayNode.init())
}
}
class LayoutExampleNode: ASDisplayNode {
override required init() {
super.init()
automaticallyManagesSubnodes = true
backgroundColor = .white
}
}
extension LayoutExampleNode {
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
let someVerticalStack = ASStackLayoutSpec.vertical()
someVerticalStack.style.flexShrink = 1.0
someVerticalStack.style.flexGrow = 1.0
let text = ASTextNode()
let attrs = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue", size: 12.0)!]
let string = NSAttributedString(string: "Hello World!", attributes: attrs)
text.attributedText = string
someVerticalStack.children = [text]
let someVerticalStackSpec = ASStackLayoutSpec(direction: .horizontal,
spacing: 40,
justifyContent: .start,
alignItems: .center,
children: [someVerticalStack])
return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10), child: someVerticalStackSpec)
}
}