iphone - How to get height of a line in UITextView -


enter image description here

as shown in above diagram ... lineheight height of orange box. how can height of blue box (i.e. lineheight + line spacing height)? thanks!

update: found the lineheight behaves differently depends on characters in content. if content in english, lineheight corrent (21, example, in default uitextview). however, when content mixed chinese characters, uifont lineheight still reported 21 while self.textview.contentsize.height increased differently:

english - adding 21 points each line chinese - adding 24 points each line 

update (sizewithfont:)

cgsize constrainedrect = cgsizemake(1000, 1000); cgsize rectenglish = [@"hello\nworld" sizewithfont:self.textview.font constrainedtosize:constrainedrect linebreakmode:uilinebreakmodewordwrap]; nslog(@"width: %.2f height: %.2f", rectenglish.width, rectenglish.height); cgsize rectchinese = [@"你\n好嗎" sizewithfont:self.textview.font constrainedtosize:constrainedrect linebreakmode:uilinebreakmodewordwrap]; nslog(@"width: %.2f height: %.2f", rectchinese.width, rectchinese.height); 

output:

width: 41.00 height: 42.00 width: 34.00 height: 42.00 

you have use

yourtextview.font.lineheight 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -