【发布时间】:2009-12-21 13:15:19
【问题描述】:
我有一个自定义按钮: My Button http://cld.ly/29ubq
我需要文本居中,这是我的代码:
NSMutableParagraphStyle *style =
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setLineBreakMode:NSLineBreakByWordWrapping];
[style setAlignment:NSLeftTextAlignment];
att = [[NSDictionary alloc] initWithObjectsAndKeys:
style, NSParagraphStyleAttributeName,
[NSColor blackColor],
NSForegroundColorAttributeName, nil];
[style release];
// other Drawing code here
[[self title] drawInRect:[self bounds] withAttributes:att];
如何将文本置于按钮中心(而不是边界中心)?
【问题讨论】:
标签: objective-c cocoa drawing custom-controls