0

i am trying to determine the size of attributedString with method

func boundingRect(with size: CGSize, options: NSStringDrawingOptions = [], context: NSStringDrawingContext?) -> CGRect

and thats my code

paragraphRect = finalString.boundingRect(with: CGSize(width:textViewExample.frame.size.width - 10, height: CGFloat(CGFloat.greatestFiniteMagnitude)), options: ([.usesLineFragmentOrigin,.usesFontLeading]), context: nil)

but i get this exception

-[_SwiftValue renderingMode]: unrecognized selector sent to instance 0x600000050110

but when i use system fonts .. it works good

Gabrail
  • 216
  • 2
  • 16

2 Answers2

2

Posting answer so others don't get confused:

UIFont(name: UIFont.lightFontName(), size: 14)!
Will Boland
  • 146
  • 2
  • 13
1

using custom font then the font should be unwrapped:

UIFont(name: UIFont.lightFontName(), size: 14)!
Gabrail
  • 216
  • 2
  • 16