iosswiftcgsize

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?


Solution

  • Just one line solution:

    yourLabel.intrinsicContentSize.width for Objective-C / Swift

    This will work even your label text have custom text spacing.