更改工具栏颜色和字体 IOS 9
change toollbar color and font IOS 9
我的故事板上有一个工具栏,想要更改颜色和 Delea 源。使用下面的代码,我可以更改颜色,但字体不会改变。怎么了?我的来源应该是 "proximaNova-Bold"
- (void)viewDidLoad {
[super viewDidLoad];
[self registerCellNamed:@"DeviceLostHeaderCell"];
[self registerCellNamed:@"DeviceLostDescriptionCell"];
[self registerCellNamed:@"DeviceLostPhotoCell"];
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor colorWithRed:82/255.0 green:157/255.0 blue:230/255.0 alpha:1.0], NSForegroundColorAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:17.0]};
NSDictionary *attributes2 = @{NSForegroundColorAttributeName : [UIColor redColor], NSForegroundColorAttributeName : [UIFont fontWithName:@"proximaNova-Regular" size:17.0]};
[self.rigthToolbarItem setTitleTextAttributes:attributes
forState:UIControlStateNormal];
[self.leftTollbarItem setTitleTextAttributes:attributes2
forState:UIControlStateNormal];
self.dataTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
这是我的工具栏:
主要问题是您正在使用键 NSForegroundColorAttributeName
并将其设置为字体,而您应该使用 NSFontAttributeName
.
NSDictionary *attributes = @{NSFontAttributeName : [UIFont fontWithName:@"ProximaNova-Bold" size:17.0]};
我的故事板上有一个工具栏,想要更改颜色和 Delea 源。使用下面的代码,我可以更改颜色,但字体不会改变。怎么了?我的来源应该是 "proximaNova-Bold"
- (void)viewDidLoad {
[super viewDidLoad];
[self registerCellNamed:@"DeviceLostHeaderCell"];
[self registerCellNamed:@"DeviceLostDescriptionCell"];
[self registerCellNamed:@"DeviceLostPhotoCell"];
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor colorWithRed:82/255.0 green:157/255.0 blue:230/255.0 alpha:1.0], NSForegroundColorAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:17.0]};
NSDictionary *attributes2 = @{NSForegroundColorAttributeName : [UIColor redColor], NSForegroundColorAttributeName : [UIFont fontWithName:@"proximaNova-Regular" size:17.0]};
[self.rigthToolbarItem setTitleTextAttributes:attributes
forState:UIControlStateNormal];
[self.leftTollbarItem setTitleTextAttributes:attributes2
forState:UIControlStateNormal];
self.dataTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
这是我的工具栏:
主要问题是您正在使用键 NSForegroundColorAttributeName
并将其设置为字体,而您应该使用 NSFontAttributeName
.
NSDictionary *attributes = @{NSFontAttributeName : [UIFont fontWithName:@"ProximaNova-Bold" size:17.0]};