Naldo Lopes Naldo Lopes - 1 month ago 37
Swift Question

CGSize sizeWithAttributes in Swift

In objective-C I was able to use:

CGSize stringsize =
[strLocalTelefone sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];


But in Swift Language I didn't found any solution for this situation.

Any Help?

Answer

what I did is something like this:

var originalString: String = "Some text is just here..."
let myString: NSString = originalString as NSString
let size: CGSize = myString.sizeWithAttributes([NSFontAttributeName: UIFont.systemFontOfSize(14.0)])
Comments