Created
January 7, 2015 15:14
-
-
Save rakeshbs/539827925df923e41afe to your computer and use it in GitHub Desktop.
animateinputaccessory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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