class HomeViewController: UIViewController, UITextFieldDelegate
{
@IBOutlet var txt_field: UITextField!
override func viewDidLoad()
{
super.viewDidLoad()
self.title = "Home View Controller"
txt_field = UITextField(frame: CGRect(x: 80, y: 300, width: 200, height: 30))
txt_field.layer.borderColor = UIColor.blackColor().CGColor
txt_field.layer.borderWidth = 1.2
txt_field.placeholder = "Text Me"
txt_field.textColor = UIColor.brownColor()
txt_field.textAlignment = NSTextAlignment.Center
txt_field.delegate = self
self.view?.addSubview(txt_field);
}
func textFieldShouldReturn(textField: UITextField!) -> Bool
{
txt_field.resignFirstResponder()
return true;
}
//Background Tabs Keyboard is hide
override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
txt_field.resignFirstResponder()
}
}
No comments:
Post a Comment