Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Vertically Centering a String within a View



I have an NSView subclass which I need to display messages in from time to time. I'm displaying these messages via the drawRect: method. I'd like to have these messages both centered horizontally and vertically.

Horizontal centering is easy and done within the string attributes. I can't seem to find a good way, however, to do the vertical centering. The string attributes are set to wrap the words, and, depending on the length of the string, the space needed can change.

It seems kind of silly that I would need to calculate the word-wrap myself, then back-track to calculate the positioning. Is there an easier way?

Thanks!

August
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.