Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var x: CGFloat = 1
- var y: CGFloat = 1
- var x1: CGFloat = 1
- var y1: CGFloat = 1
- var x2: CGFloat = 1
- var y2: CGFloat = 1
- let textfield1: UITextField = UITextField()
- let textfield2: UITextField = UITextField()
- let textfield3: UITextField = UITextField()
- textfield1.frame = CGRect(x: x+20, y: y+280, width: 300, height: 30)
- textfield1.placeholder = "Enter What you Eat BreakFast"
- textfield1.font = UIFont.systemFont(ofSize: 15)
- textfield1.borderStyle = UITextBorderStyle.roundedRect
- textfield1.autocorrectionType = UITextAutocorrectionType.yes
- textfield1.keyboardType = UIKeyboardType.default
- textfield1.returnKeyType = UIReturnKeyType.done
- textfield1.clearButtonMode = UITextFieldViewMode.whileEditing
- textfield1.contentVerticalAlignment = UIControlContentVerticalAlignment.center
- textfield1.contentHorizontalAlignment = UIControlContentHorizontalAlignment.fill
- self.view.addSubview(textfield1)
- y += 100-a
- textfield2.frame = CGRect(x: x1+20, y: y1+320, width: 100, height: 30)
- textfield2.placeholder = "Number"
- textfield2.font = UIFont.systemFont(ofSize: 15)
- textfield2.borderStyle = UITextBorderStyle.roundedRect
- textfield2.autocorrectionType = UITextAutocorrectionType.yes
- textfield2.keyboardType = UIKeyboardType.default
- textfield2.returnKeyType = UIReturnKeyType.done
- textfield2.clearButtonMode = UITextFieldViewMode.whileEditing
- textfield2.contentHorizontalAlignment = UIControlContentHorizontalAlignment.center
- textfield2.contentVerticalAlignment = UIControlContentVerticalAlignment.center
- self.view.addSubview(textfield2)
- y1 += 100-a
- textfield3.frame = CGRect(x: x2+220, y: y2+320, width: 100, height: 30)
- textfield3.placeholder = "Slect Qty"
- textfield3.font = UIFont.systemFont(ofSize: 15)
- textfield3.borderStyle = UITextBorderStyle.roundedRect
- textfield3.autocorrectionType = UITextAutocorrectionType.yes
- textfield3.keyboardType = UIKeyboardType.default
- textfield3.returnKeyType = UIReturnKeyType.done
- textfield3.clearButtonMode = UITextFieldViewMode.whileEditing
- textfield3.contentHorizontalAlignment = UIControlContentHorizontalAlignment.center
- textfield3.contentVerticalAlignment = UIControlContentVerticalAlignment.center
- self.view.addSubview(textfield3)
- y2 += 100-a
- let toolbar = UIToolbar()
- toolbar.sizeToFit()
- toolbar.backgroundColor = UIColor.brown
- let donebutton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(donepressed))
- let flexispace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
- let cancelbutton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelpressed))
- toolbar.setItems([cancelbutton,flexispace,donebutton], animated: false)
- textfield3.inputAccessoryView = toolbar
- textfield3.inputView = picker
- self.dict["Food1"] = textfield1.text!
- self.dict["Quantity"] = textfield2.text!
- self.dict["Choice"] = textfield3.text!
- }
- func donepressed()
- {
- if textfield3.isFirstResponder{
- textfield3.resignFirstResponder()
- }
- }
- func cancelpressed(){
- if textfield3.isFirstResponder{
- textfield3.resignFirstResponder()
- }
- }
- func numberOfComponents(in pickerView: UIPickerView) -> Int {
- return 1
- }
- func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
- return choose.count
- }
- func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
- return choose[row]
- }
- func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
- textfield3.text = choose[row]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement