Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialQasa Lee
18,916 Pointsfor Xcode 9 and Swift 4 there's a change we may encounter:
'NSParagraphStyleAttributeName' has been renamed to 'NSAttributedStringKey.paragraphStyle'
Hope this might help you.
Amazon Web
iOS Development Techdegree Student 4,092 PointsThanks a lot :)
3 Answers
Michael Psoinos
8,178 PointsNow it's 'NSAttributedString.Key.paragraphStyle'. (Add a "." before "Key").
Trevor Duersch
9,964 PointsIs it just me, or is part of the text cut off? After I made that change (thanks, by the way!), the text only goes to "from the surface of Mars. It's" and stops there. This is what code I have
let attributedString = NSMutableAttributedString(string: page.story.text)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))
storyLabel.attributedText = attributedString
Anybody else seeing this? Or will it get resolved in the future videos?
Jonathan Mazala
9,860 Pointsyou need to set storyLabel.numberOfLines = 0 after adding it as a subview
Joey Liu
3,982 PointsIs it just me, after I added the code . Parsan requested as below:
if let page = page { artworkView.image = page.story.artWork
let attributeString = NSMutableAttributedString(string: page.story.text)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
attributeString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributeString.length))
storyLabel.attributedText = attributeString
}
There is a Green Thread break point 1.1 at paragraphStyle = NSMutableParagraphStyle()
David Lin
35,864 PointsDavid Lin
35,864 PointsThanks, Qasa!