Aligning text with image in an NSAttributedString

I have an NSAttributedString with an image in it and I'm trying to align the text with the vertical center of the image.

This is what the string currently looks like in the table view...

[http://img195.imageshack.us/i/screenshot20110319at239.png>

Does anyone know how to align the text so it does not sit slightly below the image?

iMac 2.0ghz, Mac OS X (10.6.6), Light bulb plugged into a potato

Posted on Mar 19, 2011 2:43 PM

Reply
Question marked as ⚠️ Top-ranking reply

Posted on Mar 19, 2011 3:33 PM

You can adjust the super and subscript values within the NSAttributedString. Try something like:

 // Offset the baseline a bit.
 [RTFString
 addAttribute: NSBaselineOffsetAttributeName 
 value: [NSNumber numberWithFloat: -2.0] 
 range: NSMakeRange(0, 1)];
1 reply
Sort By: 
Question marked as ⚠️ Top-ranking reply

Mar 19, 2011 3:33 PM in response to EDLundquist

You can adjust the super and subscript values within the NSAttributedString. Try something like:

 // Offset the baseline a bit.
 [RTFString
 addAttribute: NSBaselineOffsetAttributeName 
 value: [NSNumber numberWithFloat: -2.0] 
 range: NSMakeRange(0, 1)];
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Aligning text with image in an NSAttributedString

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.