我正在尝试修改它,执行此操作:
button = [[UIBarButtonItem alloc] initWithTitle:@"Button" style:UIBarButtonItemStylePlain target:self action:@selector(test:)];
NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:12.0]};
[button setTitleTextAttributes:attributes forState:UIControlStateNormal];
这不起作用。我该怎么办?谢谢你的帮助。
答案 0 :(得分:0)
尝试将自定义按钮添加到右栏按钮,如下所示..
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, yourWidth, yourHeight);
[backButton.titleLabel setFont:[UIFont fontWithName:@"customFont" size:15.0]];
[backButton.titleLabel.text = @"yourText";
[backButton addTarget:self action:@selector(showPreviousView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc]initWithCustomView:customButton];