Search code examples
iosswiftuitoolbar

How to customize UItoolbar


Twitter Registration Page

enter image description here

Hi everyone I have some cushions about UItoolBar on swift 3/4

I'm trying to make an singIn design like twitter,

1) i create toolbar with code;

let toolBar = UIToolbar()
toolBar.sizeToFit()

let flexibleSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.done, target: self, action: #selector(self.doneClicked))


toolBar.setItems([flexibleSpace, doneButton], animated: false)
kullaniciAdi.inputAccessoryView = toolBar
eposta.inputAccessoryView = toolBar
sifre.inputAccessoryView = toolBar

but I can't add custom buttons on that. Like changing the "Done" text in my language.

2) So I created manually using Storyboard a toolBar with inside a button and Flexible Space. But ı need to "attach" that toolbar to the keyboard, so when i start to edit the textfield the toolbar will automatically show up. NOTE: it will be fantastic if the toolbar will show too when not-editing textField. Like that:

My app trying too attach toolbar

enter image description here

THANK YOU ALL


Solution

  • In Code

    let sonrakiButton = UIBarButtonItem(title: "Sonraki", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.sendDoneBtnAction))
    

    For more info, read this link