swift中系統(tǒng)通知名修改對(duì)照:

鍵盤狀態(tài)改變的時(shí)候,系統(tǒng)會(huì)發(fā)出一些特定的通知

UIKeyboardWillShowNotification//鍵盤即將顯示

UIKeyboardDidShowNotification//鍵盤顯示完畢

UIKeyboardWillHideNotification//鍵盤即將隱藏

UIKeyboardDidHideNotification//鍵盤隱藏完畢

UIKeyboardWillChangeFrameNotification//鍵盤的位置尺寸即將發(fā)生改變

UIKeyboardDidChangeFrameNotification//鍵盤的位置尺寸改變完畢

系統(tǒng)發(fā)出鍵盤通知時(shí),會(huì)附帶一下跟鍵盤有關(guān)的額外信息(字典),字典常見的key如下:

UIKeyboardFrameBeginUserInfoKey//鍵盤剛開始的frame

UIKeyboardFrameEndUserInfoKey//鍵盤最終的frame(動(dòng)畫執(zhí)行完畢后)

UIKeyboardAnimationDurationUserInfoKey//鍵盤動(dòng)畫的時(shí)間

UIKeyboardAnimationCurveUserInfoKey//鍵盤動(dòng)畫的執(zhí)行節(jié)奏(快慢)

UIKeyboardAnimationCurveUserInfoKey = 7; //動(dòng)畫執(zhí)行的節(jié)奏

UIKeyboardAnimationDurationUserInfoKey = "0.25";鍵盤彈出/隱藏的動(dòng)畫所需要的時(shí)間

UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}”;//鍵盤的bounds

UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 588}”;//鍵盤準(zhǔn)備彈出時(shí)的X,Y的中心坐標(biāo)

UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 372}”;//鍵盤彈出后的X,Y的中心坐標(biāo)

//鍵盤彈出剛開始的那一刻的frame

UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 216}}";

//彈出完畢的時(shí)候,鍵盤的frame

UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 264}, {320, 216}}";

//鍵盤退出的frame

//鍵盤剛要退出那一刻的frame

UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 264}, {320, 216}}";

//鍵盤退出完畢那一刻的frame

UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 480}, {320, 216}}";



以下是swift:


extension NSNotification.Name {

public static let UIWindowDidBecomeVisible: NSNotification.Name

public static let UIWindowDidBecomeHidden: NSNotification.Name // nil

public static let UIWindowDidBecomeKey: NSNotification.Name // nil

public static let UIWindowDidResignKey: NSNotification.Name // nil

public static let UIKeyboardWillShow: NSNotification.Name

public static let UIKeyboardDidShow: NSNotification.Name

public static let UIKeyboardWillHide: NSNotification.Name

public static let UIKeyboardDidHide: NSNotification.Name

@available(iOS 5.0, *)

public static let UIKeyboardWillChangeFrame: NSNotification.Name

@available(iOS 5.0, *)

public static let UIKeyboardDidChangeFrame: NSNotification.Name

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,991評(píng)論 19 139
  • 在ios開發(fā)中,鍵盤很常用。在sdk版本5.0以前,鍵盤高度是固定值216px;5.0出來以后,鍵盤高度會(huì)隨著鍵盤...
    petter102閱讀 3,479評(píng)論 1 1
  • 通知中心(NSNotificationCenter) 通知(NSNotification) 一個(gè)完整的通知一般包含...
    JonesCxy閱讀 521評(píng)論 0 1
  • SwiftDay011.MySwiftimport UIKitprintln("Hello Swift!")var...
    smile麗語閱讀 3,865評(píng)論 0 6
  • 運(yùn)道極差,30雙草鞋僅賣了5雙。劉玄德背著麻布包袱緩緩回轉(zhuǎn)。這是位年28歲的青年男子,生的俊朗,膚色白皙,若非尋常...
    開顏棠棠閱讀 538評(píng)論 2 2