标签:
+(void)initialize{ UINavigationBar *item = [UINavigationBar appearance]; // 按钮的颜色 item.tintColor = [UIColor redColor]; // 整个背景的颜色 item.barTintColor = [UIColor orangeColor]; }
NSMutableDictionary *dic = [NSMutableDictionary dictionary]; dic[NSForegroundColorAttributeName] = [UIColor whiteColor]; UINavigationBar *item = [UINavigationBar appearance]; [item setTitleTextAttributes:dic]; [item setBackgroundImage:[UIImage imageNamed:@"top"] forBarMetrics:UIBarMetricsDefault];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [btn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [btn setBackgroundImage:[UIImage imageNamed:@"back_hover"] forState:UIControlStateSelected]; [btn setTitle:@"返回" forState:UIControlStateNormal]; btn.titleLabel.font = [UIFont systemFontOfSize:15]; [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; btn.size = CGSizeMake(50, 29); // btn.backgroundColor = [UIColor lightGrayColor]; // btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; // btn.contentEdgeInsets = UIEdgeInsetsMake(0, -50, 0, 0); [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
标签:
原文地址:http://www.cnblogs.com/kinghx/p/5263144.html