1

嗨,我对 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];

4

1 回答 1

4

我认为字体的正确名称是Verdana而不是Vardana. 您可以在http://iphonedevsdk.com/forum/iphone-sdk-development/6000-list-of-uifonts-available.html中查看几种字体的名称

于 2012-10-24T06:51:01.013 回答