我正在使用以下代码来创建我的工具栏按钮......我想将文本颜色更改为黑色或更好......将背景图像设置为文本着色......setBackgroundColor 不起作用...... ..任何帮助表示赞赏,谢谢。
UIButton *btnEditLogin = [UIButton buttonWithType:UIButtonTypeCustom];
[btnEditLogin setBackgroundImage:[UIImage imageNamed:@"btnPlain.png"] forState:UIControlStateNormal];
[btnEditLogin setTitle:@"Edit Login" forState:UIControlStateNormal];
[btnEditLogin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
btnEditLogin.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
[btnEditLogin.layer setCornerRadius:5.0f];
[btnEditLogin.layer setMasksToBounds:YES];
[btnEditLogin.layer setBorderWidth:1.0f];
[btnEditLogin.layer setBorderColor: [[UIColor brownColor] CGColor]];
btnEditLogin.frame=CGRectMake(0.0, 100.0, 90.0, 30.0);
[btnEditLogin addTarget:self action:@selector(LoginBtn) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *editLoginItem = [[UIBarButtonItem alloc] initWithCustomView:btnEditLogin];