How to change keyboard background color in iOS?

前端 未结 8 1700
一整个雨季
一整个雨季 2020-12-02 16:51

I would like to know how to change the keyboard background color programmatically in iOS? The background is normally grey but I have already seen black background (behind le

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 17:27

    In iOS 7, UIKeyboardAppearanceAlert is deprecated, so use this instead:

    mytextfield.keyboardAppearance = UIKeyboardAppearanceDark;
    

    If you need to support both earlier iOSes and iOS 7, and you've created the necessary macros (per https://stackoverflow.com/a/5337804/588253), you can use this:

    mytextfield.keyboardAppearance = (SYSTEM_VERSION_LESS_THAN(@"7.0") ? UIKeyboardAppearanceAlert : UIKeyboardAppearanceDark);
    

提交回复
热议问题