开发者

Format button text in Cocoa application

I am re-visiting my calculator application and am now trying to tighten up the interface to make it look nicer so I was wondering how or if it's possible to format 开发者_JAVA技巧the text of a button.

For example, I currently have the '1' button with a plain gray control and black character in the center of the button, but is there a way to move the character to, say, the upper left corner of the button?


Use NSButton's -setAttributedTitle: method to send it an attributed string. for basic formatting.

For anything "fancy", however, you'll likely have to subclass NSButtonCell and handle the drawing yourself using one of the "draw with attributes" methods with a custom NSParagraphStyle as one of the attributes for paragraph alignment, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜