Crash 1
Issue is with this code:
[_labelText drawInRect:textRect withAttributes:textFont];
2nd parameter of drawInRect:withAttributes:
method expects NSDictionary
, you are passing UIFont
object. That is the reason for the crash.
You should do something like:
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: textFont,NSFontAttributeName,nil];
[_labelText drawInRect:textRect withAttributes:dict];
or
You can use: drawInRect:withFont
method instead.
[_labelText drawInRect:rect withFont:textFont];
Crash 2
In the following code:
CGSize textSize = [_labelText sizeWithAttributes:textFont];
here also the parameter is wrong, sizeWithAttributes:
method expects NSDictionary
, you are passing UIFont
object.
Change that to:
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: textFont,NSFontAttributeName,nil];
CGSize textSize = [_labelText sizeWithAttributes:dict];