Twitter Registration Page
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
THANK YOU ALL
In Code
let sonrakiButton = UIBarButtonItem(title: "Sonraki", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.sendDoneBtnAction))
For more info, read this link
Related
Can someone help me with how I could inline the add button with the navigation panel? Its shown below the panel.
This is the code I used:
let add = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: nil)
self.navigationItem.rightBarButtonItem = add
There is an additional pane with buttons appears in messages app on iPhone when tapping Edit button. See link, screenshot.
Messages app on iPhone
Is it a default UITableView property? (Probably not)
Is it a UIView, showing over tableView with delegate methods for handling buttons actions?
I searched everywhere with no luck. Can you give me the cue, how I can make the same one myself?
My app is written in Swift.
It's probably a UIToolbar. Just add it at the bottom of your viewcontroller's view.
Thanks to all, you were right, it is a UIToolbar, and it is quite easy to use.
To create toolbar:
let toolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 50))
toolbar.barStyle = UIBarStyle.default
toolbar.items = [
UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: #selector(cancelAction)),
UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "Next", style: UIBarButtonItemStyle.plain, target: self, action: #selector(nextAction))]
toolbar.sizeToFit()
To show it:
view.addSubview(toolbar)
To remove it:
toolbar.removeFromSuperView
I have two buttons inside of a toolbar that is positioned at the bottom of the screen. I would like to center those buttons within the toolbar. Everything I have found is focused on centering buttons within a nav bar and I am unsure of how to approach this issue. What am I missing?
This is the UI I am attempting to emulate:
Adding a flexible space to the left and right of the buttons centered the buttons inside of the toolbar. Thanks to Midhun MP for the tip.
Thks #Andrew, it works
but for someone who wants it from code here is the example in Swift 5.0
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.setToolbarHidden(false, animated: true)
let spaceItemLeft = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
let nextItem = UIBarButtonItem(title: "NEXT", style: .plain, target: self, action: #selector(nextTapped))
let spaceItemRight = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
toolbarItems = [spaceItemLeft, nextItem, spaceItemRight]
}
#objc func nextTapped() {
print("NEXT Tapped")
}
From past few days i am trying to generate a popover for programmatically added UIBarButtonItem but i couldn't succeed. Added to this, i even want this popover to be presented with few images sequentially which are clickable. The following is the code of how i generated a UIBarButtonItem programmatically
func imagerendering(){
let barbuttonimage = UIImage(named: "app")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
let button1 = UIBarButtonItem(image: barbuttonimage, style: .Plain, target: self, action: nil)
self.navigationItem.leftBarButtonItem = button1
let attachButtonImage = UIImage(named: "icon-Attach")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
let attachButton = UIBarButtonItem(image: attachButtonImage, style: UIBarButtonItemStyle.Plain, target: self, action: nil)
self.navigationItem.setRightBarButtonItems([menuButton,attachButton], animated: true)
let fixedSpace:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
fixedSpace.width = 5.0
self.navigationItem.rightBarButtonItems = [menuButton, fixedSpace, attachButton]
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIFont(name: "Avenir-Black", size: 16)!]
}
I have presented my desired output in an image as a link below. please go through it and let me know whether what i am desiring is possible or not.
desired output image
To add an extra bar item on navigation bar using storyboard, you can refer these answers
After that, set a popover from storyboard(you know it well as you said) and then put required buttons with actions in your popop view. You can set image for a button instead of title text.
Look into the WYPopoverController library. It gives you the functionality you're looking for.
In an iOS app I am making, I have set the identifier of a bar button item programmatically using:
homeTitleBar.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Trash, target: self, action: nil)
Which changes the button to a trash can.
My question is, after that, how can I then change it to a custom image.
homeTitleBar.leftBarButtonItem?.image = UIImage(named: "settingsIcon")
does not seem to be working.
Try
homeTitleBar.leftBarButtonItem = UIBarButtonItem(image:UIImage(named: "settingsIcon"), style: UIBarButtonItemStyle.Plain, target: self, action: nil)