我需要知道调用后,UISearchBar的取消按钮何时完成了他的动画
searchBar.setShowsCancelButton(false, animated: true)
我已经试过了
UIView.animateWithDuration(3, animations: {
self.searchBarView.searchBar.showsCancelButton = false
}, completion: {finished in
print(finished)
})
但是完成块会立即触发,任何解决方案将不胜感激
您可以使用layoutIfNeeded()更新UIView.animateWithDuration(...)中的视图
试试这个代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var searchBar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func touchUpInside(sender: UIButton) {
searchBar.showsCancelButton = !searchBar.showsCancelButton
UIView.animateWithDuration(3, animations: {
self.searchBar.layoutIfNeeded()
}, completion: {finished in
print("Animation finished")
})
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句