Reputation: 933
Getting this error on size = text.boundingRectWithSize
Cannot convert value of type '[String : AnyObject]?.Type' (aka 'Optional>.Type) to expected argument type '[String : AnyObject]?'
func heightOfString(text: NSString!, width: CGFloat, font: UIFont) -> CGFloat{
var ch:CGFloat!
var size:CGSize = CGSizeMake(width, CGFloat.max)
var tdic:NSDictionary = NSDictionary(objects: [font, NSFontAttributeName], forKeys: [])
size = text.boundingRectWithSize(size, options: NSStringDrawingOptions.UsesFontLeading , attributes: [String : AnyObject]?, context: nil).size
ch = size.height
return ch
}
Upvotes: 1
Views: 4608
Reputation: 70097
If you need to pass an empty dictionary for the attributes, use [:]
size = text.boundingRectWithSize(size, options: NSStringDrawingOptions.UsesFontLeading , attributes: [:], context: nil).size
Upvotes: 2