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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -