ios - Converting sizeWithFont:constrainedToSize to boundingRectWidth -


so cam across 1 old ios project , following line says deprecated:

cgsize stringsize = [string sizewithfont:self.stringlabel.font constrainedtosize:cgsizemake(200, 300)]; 

it says should use boundingrectwidth if try with

cgsize stringsize = [string sizewithfont:self.stringlabel.font boundingrectwidth:cgsizemake(200, 300)];  

i trying upgrade deploy target 9.0 because 1 of libs build 7.0 + thats why realy must update this. says not exists, idea doing wrong?

you can try out following code. can pass dictionary of attributes while calling boundingrectwithsize. in case dictionary contain font attribute.

cgrect stringsize = [string boundingrectwithsize:cgsizemake(200, 300) options:nsstringdrawinguseslinefragmentorigin attributes:@{nsfontattributename: self.stringlabel.font} context:nil]; 

hope helps!


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -