首页 > 代码库 > 自定义导航条 文字大小颜色等 按钮大小图标等 背景色
自定义导航条 文字大小颜色等 按钮大小图标等 背景色
UIButton *leftBtn = [UIButtonbuttonWithType:UIButtonTypeCustom];
[leftBtn setTitleColor:lightBlueforState:UIControlStateNormal];
leftBtn.backgroundColor = [UIColorclearColor];
leftBtn.frame =CGRectMake(0,0, 60, 44);
[leftBtn addTarget:selfaction:@selector(backClick)forControlEvents:UIControlEventTouchUpInside];
UIImageView *backImage = [[UIImageViewalloc]initWithFrame:CGRectMake(0,12, 12, 20)];
backImage.image = [UIImageimageNamed:@"back"];
[leftBtnaddSubview:backImage];
UILabel* middleLabel = [[UILabelalloc]init];
middleLabel.textColor = [UIColorwhiteColor];
middleLabel.frame =CGRectMake(0,0, 120, 44);
middleLabel.textAlignment =NSTextAlignmentCenter;
middleLabel.font = [UIFontboldSystemFontOfSize:24.0];
middleLabel.backgroundColor = [UIColorclearColor];
middleLabel.text =@"XXXX";
UIBarButtonItem *left = [[UIBarButtonItemalloc]initWithCustomView:leftBtn];
self.navigationItem.leftBarButtonItem = left;
self.navigationItem.titleView = middleLabel;
if (version<7.0) {
self.navigationController.navigationBar.tintColor = lightBlue;
}else {
self.navigationController.navigationBar.barTintColor = lightBlue;
self.navigationController.navigationBar.translucent = NO;
}
自定义导航条 文字大小颜色等 按钮大小图标等 背景色