Open
Description
From @d6u on September 6, 2015 1:58
let fontHeight = CGFloat(19.25)
let fontSize = CGFloat(16)
let lineSpace = CGFloat(10)
// Red Strip
for i in 0...10 {
let v = UIView(frame: CGRect(x: 0, y: CGFloat(150) + CGFloat(i) * (fontHeight + lineSpace), width: 320, height: fontHeight))
v.backgroundColor = UIColor.redColor()
view.addSubview(v)
}
// String
let style = NSMutableParagraphStyle()
style.lineSpacing = lineSpace
let text = NSAttributedString(string: "Lorem Ipsum is simplyry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make 👍 a type specimen book.", attributes: [
NSFontAttributeName: UIFont.systemFontOfSize(16),
NSParagraphStyleAttributeName: style
])
// ASTextNode
let textNode = ASTextNode()
textNode.attributedString = text
textNode.measure(CGSize(width: 200, height: CGFloat.max))
textNode.frame = CGRect(origin: CGPoint(x: 50, y: 150), size: textNode.calculatedSize)
textNode.backgroundColor = UIColor.purpleColor()
view.addSubnode(textNode)
// Normal Text Label
let textLabel = UILabel(frame: CGRect(x: 50, y: 150, width: 200, height: 100))
textLabel.attributedText = text
textLabel.numberOfLines = 0
textLabel.sizeToFit()
view.addSubview(textLabel)
So I added two text label with the same attributed string. The line with 👍 won't agree with each other. I also added red strip as reference.
How do I render consistent line space using TextNode? Did I miss some config?
Copied from original issue: facebookarchive/AsyncDisplayKit#639