[MacRuby-devel] How do we center label text?

azzzz at gmx.net azzzz at gmx.net
Fri May 27 08:59:53 PDT 2011

Thanks Shannon - I managed to work it out with your help:

self.label.alignment = NSCenterTextAlignment

I've also worked out (2) too :-)

self.img.hidden = false does the trick :)

On 27 May 2011, at 02:34, azzzz at gmx.net wrote:

> Couple of quick questions I hope someone can help with.
> 1. How do we center text in labels?
> I have a text label, and it is set to blank (text deleted via interface builder) but when the text comes in I'd like it to center, any ideas how to do it? I'm setting my label via self.label.stringValue.
> I've googled and tried this but it doesn't seem to work: self.label.textAlignment = UITextAlignmentCenter
> 2. Is it possible to add images to the window (via interface builder - this bit I can do) but set them to hide and then only show them if I need to via my ruby code? Once I make the connection to an image how would I do that?
> Sorry to be a pita - hope someone can help.
> Cheers.
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

More information about the MacRuby-devel mailing list