Option 2 does work in iOS with the proper parameters.
NSAttributedString *attrStr = ... // your attributed string
CGFloat width = 300; // whatever your desired width is
CGRect rect = [attrStr boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
Without the proper values for the options
parameter you will get the wrong height.
It is also required that attrStr
contains a font attribute. Without a font, there is no way to properly calculate the size.