I'm trying to determine the height of a block of text so that I can set a view to the correct height for a scrollview. The text is placed on the screen in a UILabel. The string is long enough that it will wrap.
I've tried a bunch of different approaches with no success. I'm new to programming, and I can find examples of people doing this in Obj-C, but when I try replicating what they did in Swift, I don't get what they're getting – instead, I consistently get a value of 27.6 (even if I change the font size). Here's my best thinking thus far:
var font : UIFont = UIFont()
var attrs : [NSObject: AnyObject] = [font:UIFont.boldSystemFontOfSize(20.0)]
var theSize = (someObject.someString as NSString).boundingRectWithSize( CGSizeMake(300.0, CGFloat.max), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes:attrs, context:nil).size
println(theSize.height)
So, I'm stuck...How do I get the height of this block of text in Swift?