NSButton setAlignment no funciona
Solí
[button setAlignment:NSCenterTextAlignment];
para que el texto se muestre en el centro del botón.
Funcionó
Pero si configuro el atributo del título del botón antes del código, el botón 'setAlignment' no funcionará
- (void)setButtonTitle:(NSButton*)button fontName:(NSString*)fontName fontSize:(CGFloat)fontSize fontColor:(NSColor*)fontColor;
{
NSMutableAttributedString *attributedString =
[[NSMutableAttributedString alloc] initWithString:[button title]
attributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:fontName size:fontSize]
forKey:NSFontAttributeName]];
[attributedString addAttribute:NSForegroundColorAttributeName
value:fontColor
range:NSMakeRange(0, [[button title] length] )];
[button setAttributedTitle: attributedString];
[button setAlignment:NSCenterTextAlignment];//button title alignment always displayed as 'NSLeftTextAlignment' rather than 'NSCenterTextAlignment'.
}
alineación de títulos siempre se muestra como 'NSLeftTextAlignment' en lugar de 'NSCenterTextAlignment'.
Bienvenido cualquier comentario