iOS 系統(tǒng)自帶的短信軟件 iMessage 和備忘錄都是往下拉到鍵盤范圍才會收起鍵盤缩抡,其實這個效果蘋果已經封裝好了奠宜,不需要自己實現。
UIScrollViewKeyboardDismissModeNone,
// dismisses the keyboard when a drag begins
UIScrollViewKeyboardDismissModeOnDrag,
// the keyboard follows the dragging touch off screen, and may be pulled upward again to cancel the dismiss
// 鍵盤會跟隨你的拉動而消失瞻想,如果要取消這個動作需要你再次往上拉
UIScrollViewKeyboardDismissModeInteractive,
只要讓你的 ScrollView 的 keyboardDismissMode Property 設定為 UIScrollViewKeyboardDismissModeInteractive
就可以啦压真!