Skip to content

Instantly share code, notes, and snippets.

@rakeshbs
Created January 7, 2015 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakeshbs/539827925df923e41afe to your computer and use it in GitHub Desktop.
Save rakeshbs/539827925df923e41afe to your computer and use it in GitHub Desktop.
animateinputaccessory
class ViewController: UIViewController,UITextFieldDelegate {
@IBOutlet var textField: UITextField!
var backgroundView : UIView!
var sendButton: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
override func viewDidLoad() {
super.viewDidLoad()
sendButton.frame = CGRectMake(0, 60, UIScreen.mainScreen().applicationFrame.width, 30)
sendButton.backgroundColor = UIColor(red: 184/255.0, green: 56/255.0, blue: 56/255.0, alpha: 1)
sendButton.setTitle("Send", forState: .Normal)
sendButton.addTarget(self, action: "sendNotification", forControlEvents: UIControlEvents.AllEvents)
textField.delegate = self
backgroundView = UIView()
backgroundView.frame = CGRectMake(0, 0, UIScreen.mainScreen().applicationFrame.width, 90)
backgroundView.backgroundColor = UIColor.clearColor()
backgroundView.addSubview(sendButton)
}
func sendNotification(){
UIView.animateWithDuration(1, animations: {
self.sendButton.frame = CGRectMake(0, 0, UIScreen.mainScreen().applicationFrame.width, 90)
self.sendButton.backgroundColor = UIColor(red: 300/255.0, green: 56/255.0, blue: 56/255.0, alpha: 1)
self.sendButton.setTitle("Hello", forState: .Normal)
})
}
func textFieldDidBeginEditing(textField: UITextField) {
textField.inputAccessoryView = self.backgroundView
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment