[分享]iOS開發-設定NavigationBar的顏色和字型屬性

ShevaKuilin發表於2016-03-07

程式碼如下:

#define kColorBarTint   [UIColor colorWithRed:56/255.0 green:170/255.0 blue:27/255.0 alpha:1.0]


#import "SSMyViewController.h"

@interface SSMyViewController ()

@end

@implementation SSMyViewController

-(void)viewDidLoad {
    [super viewDidLoad];
    //set NavigationBar 背景顏色&title 顏色
    [self.navigationController.navigationBar setBarTintColor:kColorBarTint];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:22],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
}

-(void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end

相關文章