Ios UIPickerView BarButton文本颜色未更改,但单击按钮时,颜色在Objective-C中更改
我有一个问题,我已经将Ios UIPickerView BarButton文本颜色未更改,但单击按钮时,颜色在Objective-C中更改,ios,objective-c,uipickerview,uibarbuttonitem,Ios,Objective C,Uipickerview,Uibarbuttonitem,我有一个问题,我已经将UIPickerViewBarButton标题颜色设置为蓝色,但它没有提供完美的输出,但当我单击该按钮时,它会提供输出,这意味着它会将颜色更改为蓝色,但我不希望仅在单击后才使用蓝色,我希望按钮在单击前使用蓝色。那我该怎么做呢 代码: 我的代表没有完成导航代码: [[UINavigationBar appearance] setBarTintColor:FooterBGColor]; [[UINavigationBar appearance] setTintColor:[
UIPickerView
BarButton
标题颜色设置为蓝色,但它没有提供完美的输出,但当我单击该按钮时,它会提供输出,这意味着它会将颜色更改为蓝色,但我不希望仅在单击后才使用蓝色,我希望按钮在单击前使用蓝色。那我该怎么做呢
代码:
我的代表没有完成导航代码:
[[UINavigationBar appearance] setBarTintColor:FooterBGColor];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
if (@available(iOS 11.0, *)) {
[[UINavigationBar appearance] setLargeTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
} else {
}
在Donebutton中使用着色颜色 试试这个
UIBarButtonItem *donebutton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Btn_DoneClick)];
// donebutton.style=UIBarButtonItemStylePlain;
donebutton.tintColor = [UIColor blueColor];
我知道这个问题是10个月前提出的。但今天我仍然有这个问题。我试着改变色调,但我不知道为什么它不起作用。花了几个小时之后,我终于决定在UIToolbar上创建一个UIView,然后在上面添加一个UIButton。这对我有用。我希望它能在将来帮助别人
// UIPickerView
self.myPickerView = UIPickerView(frame:CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 216))
self.myPickerView.delegate = self
self.myPickerView.dataSource = self
self.myPickerView.backgroundColor = UIColor.white
cell.myTextField.inputView = self.myPickerView
// ToolBar
let toolBar = UIToolbar()
toolBar.barStyle = .default
toolBar.isTranslucent = true
toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue: 255/255, alpha: 1)
toolBar.sizeToFit()
// UIView
let myNewView=UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 44))
myNewView.backgroundColor = .lightGray
toolBar.addSubview(myNewView)
// UIButton
let button:UIButton = UIButton(frame: CGRect(x: myNewView.bounds.width - 80, y: 0, width: 70, height: 44))
button.setTitle("Done", for: .normal)
button.addTarget(self, action:#selector(self.doneClick), for: .touchUpInside)
myNewView.addSubview(button)
cell.myTextField.inputAccessoryView = toolBar
我已经试过你的代码和它显示的“完成”按钮正确。我在AppDelegate中写了一些代码,我只是在这里更新代码,请检查一下,我不知道为什么会发生这种情况!我也尝试过appdelegate代码,这也很好。一定是从其他代码中断。不确定,你能试试这个吗&Great:)快乐编码!让tool=UIToolbar();tool.barStyle=UIBarStyle.default tool.isTranslucent=true tool.tintColor=UIColor.blue tool.sizeToFit()tool.barTintColor=UIColor.blue tool.backgroundColor=UIColor.white//这是swift代码,我希望你能在目标c中转换。我尝试了一下,这代码在@Pradip仍然不起作用,我想我们错过了一些东西!!
// UIPickerView
self.myPickerView = UIPickerView(frame:CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 216))
self.myPickerView.delegate = self
self.myPickerView.dataSource = self
self.myPickerView.backgroundColor = UIColor.white
cell.myTextField.inputView = self.myPickerView
// ToolBar
let toolBar = UIToolbar()
toolBar.barStyle = .default
toolBar.isTranslucent = true
toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue: 255/255, alpha: 1)
toolBar.sizeToFit()
// UIView
let myNewView=UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 44))
myNewView.backgroundColor = .lightGray
toolBar.addSubview(myNewView)
// UIButton
let button:UIButton = UIButton(frame: CGRect(x: myNewView.bounds.width - 80, y: 0, width: 70, height: 44))
button.setTitle("Done", for: .normal)
button.addTarget(self, action:#selector(self.doneClick), for: .touchUpInside)
myNewView.addSubview(button)
cell.myTextField.inputAccessoryView = toolBar