You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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

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.