Picker with additional text?

Hi guys,

I really would like to show additional text while using the picker, may be left from "done", is that possible? See screenshot

Thank you and best regards
Chris

Tagged:

Best Answer

Answers

  • ChristianKroesChristianKroes USMember ✭✭

    That's it! And so easy ;) Thank you!!!

    Any chance to change the text color of "Fertig" (Done)? And may be add an Cancel Button? Didn't find anything yet :(

    Best regards
    Chris

  • ChristianKroesChristianKroes USMember ✭✭

    I found out to change color of "Done" with view.TintColor ;) But any chance for a cancel button?

  • ColeXColeX Member, Xamarin Team Xamurai

    You could customize everything on the InputAccessoryView , but you should create a new UIView instead .

      if(Control != null)
            {
                UITextField textField = Control;
    
                //new a UIView
                UIView view = new UIView(frame:new CGRect(0,0,UIScreen.MainScreen.Bounds.Width, 40));
                view.BackgroundColor = UIColor.FromRGB(new nfloat(200), new nfloat(200), new nfloat(200));
    
                //top border
                CALayer topBorder = CALayer.Create();
                topBorder.Frame = new CGRect(0, 0, view.Frame.Width, 1);
                topBorder.BackgroundColor = UIColor.Gray.CGColor;
                view.Layer.AddSublayer(topBorder);
    
                // left label
                UILabel label = new UILabel();
                label.Frame = view.Frame;
                label.Text = "Test";
                view.Add(label);
    
    
                //right button
                UIButton button = new UIButton();
                button.Frame = new CGRect(view.Frame.Width -70, 0, 70, 40);
                button.SetTitle("Cancel", UIControlState.Normal);
                button.SetTitleColor(UIColor.Green, UIControlState.Normal);
                button.TouchUpInside += (sender, e1) =>
                {
                    textField.ResignFirstResponder();
                };
                view.Add(button);
    
                textField.InputAccessoryView = view;
            }
    

Sign In or Register to comment.