UIPickerView
BarButton
タイトルの色を青に設定しましたが、完全な出力が得られないという問題がありますが、そのボタンをクリックすると、色が青に変わることを意味する出力が表示されますが、クリックした後にのみ青い色は必要ありません。ボタンが必要です。クリックする前に青色。どうすればこれを行うことができますか?
コード:
-(void)SetToolbar
{
//******* add buttons in toolbar
self.toolbar=[[UIToolbar alloc]init];
self.toolbar.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight| UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin );
self.toolbar.frame=CGRectMake(0, self.currencypicker.frame.origin.y, self.currencypicker.frame.size.width, 45);
self.toolbar.barStyle=UIBarStyleDefault;
self.toolbar.backgroundColor=[UIColor whiteColor];
self.toolbar.tintColor=[UIColor blueColor];
UIBarButtonItem *donebutton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Btn_DoneClick)];
// donebutton.style=UIBarButtonItemStylePlain;
UIBarButtonItem *cancelbutton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(Btn_CancelClick)];
UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIView *titleview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 150, 40)];
titleview.backgroundColor=[UIColor clearColor];
UILabel *lbltitle=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 40)];
lbltitle.backgroundColor=[UIColor clearColor];
lbltitle.textAlignment=NSTextAlignmentCenter;
lbltitle.text=@"Payment Type";
lbltitle.font=[UIFont boldSystemFontOfSize:17.0];
if(IS_IPAD)
{
lbltitle.textColor=[UIColor colorWithRed:113.0/256 green:120.0/256 blue:128.0/256 alpha:1.0];
}
else
{
lbltitle.textColor=[UIColor blackColor];
}
[titleview addSubview:lbltitle];
UIBarButtonItem *btnAdd=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPaymentClicked)];
UIBarButtonItem *titlebutton = [[UIBarButtonItem alloc] initWithCustomView:titleview];
NSArray *items = [NSArray arrayWithObjects:cancelbutton,flex,titlebutton,flex,btnAdd, donebutton, nil];
[self.toolbar setItems:items animated:NO];
[self.view addSubview:self.toolbar];
[self.view bringSubviewToFront:self.pickerView];
//*******
}
ナビゲーション用の私の代理人DidFinishCode:
[[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 {
}
私はこの質問が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
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加