我已经以编程方式创建了一个条形按钮项。现在它看起来简单的文字。我需要设置没有边框的背景颜色,还需要以编程方式设置色调颜色。 这是我创建一个条形按钮项的代码:
UIBarButtonItem *callBtn = [[UIBarButtonItem alloc] initWithTitle:@"Call Me" style:UIBarButtonItemStylePlain target:self action:@selector(signUpButtonTapped:)];
self.navigationItem.rightBarButtonItem = callBtn;
背景颜色应为:#F9F9F9
色调颜色应为:00ACC1
请帮我做
我需要这样的形象:
答案 0 :(得分:2)
使用自定义按钮进行自定义控制 以下代码可能会有所帮助
SSRS
答案 1 :(得分:1)
在你的Appdelegate中设置Bar色调:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIColor *barColor = [UIColor colorWithRed:0 green:172/255.0 blue:193/255.0 alpha:1.0];
[[UINavigationBar appearance]setBarTintColor: barColor];
return YES;
}
现在在您的视图控制器中:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0,0,80,30);
[btn addTarget:self action:@selector(signUpButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
UIColor *barColor = [UIColor colorWithRed:0 green:172/255.0 blue:193/255.0 alpha:1.0];
[btn setTitle:@"Call Me" forState:UIControlStateNormal];
[btn setTitleColor:barColor forState:UIControlStateNormal];
btn.backgroundColor = [UIColor lightGrayColor];
UIBarButtonItem *callBtn =[[UIBarButtonItem alloc]initWithCustomView:btn];
self.navigationItem.rightBarButtonItem = callBtn;