我想在用户开始输入时为文本字段设置动画以取左按钮空间,我厌倦了隐藏按钮并更改了constinet但没有任何效果
import UIKit
class ViewController: UIViewController,UITextFieldDelegate,UIAlertViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIPopoverControllerDelegate {
var chat = []
@IBOutlet var imageView: UIImageView!
@IBOutlet var textFieldWidth: NSLayoutConstraint!
@IBOutlet var chatTableview: UITableView!
@IBOutlet var textField: UITextField!
@IBOutlet var chatViewHeight: NSLayoutConstraint!
@IBOutlet var chatView: UIView!
@IBOutlet var sendButton: UIButton!
@IBOutlet var cameraButton: UIButton!
func textFieldDidBeginEditing(textField: UITextField) {
self.view.layoutIfNeeded()
UIView.animateWithDuration(0.1, animations: {
self.chatViewHeight.constant = 300
self.textFieldWidth.constant = 520
self.view.layoutIfNeeded()
self.sendButton.hidden = true
}, completion: nil)
}
func textFieldDidEndEditing(textField: UITextField) {
self.view.layoutIfNeeded()
UIView.animateWithDuration(0.3, animations: {
self.chatViewHeight.constant = 40
self.view.layoutIfNeeded()
}, completion: nil)
self.sendButton.hidden = false