嗨我有titleLabel属性的问题。当我想改变它。这些变化并非如此。 这是我的代码:
UIButton *menuItemButton = [[UIButton alloc] initWithFrame:CGRectMake(x, y, 290.0, 35.0)];
[menuItemButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[menuItemButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
menuItemButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[menuItemButton setContentEdgeInsets:UIEdgeInsetsMake(0, 11.0, 0, 0)];
[menuItemButton setTitle:(NSString *)[itemParams objectForKey:@"Name"] forState:UIControlStateNormal];
[menuItemButton setBackgroundImage:menuItemImage forState:UIControlStateNormal];
[menuItemButton setTag:idx];
[[menuItemButton titleLabel] setFont:[UIFont fontWithName:@"Vardana" size:5]];
[menuItemButton addTarget:self action:@selector(menuItemClicked:) forControlEvents:UIControlEventTouchUpInside];
这不起作用:
[[menuItemButton titleLabel] setFont:[UIFont fontWithName:@"Vardana" size:15]];
我也尝试:
[menuItemButton.titleLabel setFont:[UIFont fontWithName:@"Vardana" size:15]];
menuItemButton.titleLabel.font = [UIFont fontWithName:@"Vardana" size:15];
titleLabel的其他属性也不适用于ex。对齐和颜色。
我在viewDidLoad
[super viewDidLoad];
写的所有文字
答案 0 :(得分:4)
我认为字体的正确名称是Verdana
而不是Vardana
。您可以在http://iphonedevsdk.com/forum/iphone-sdk-development/6000-list-of-uifonts-available.html