【问题标题】:ios How to changed the upper keyboard bar color and button color?ios如何更改上键盘栏颜色和按钮颜色?
【发布时间】:2014-04-07 05:46:35
【问题描述】:

如何改变上键盘栏颜色和按钮颜色?

我设置了文本字段委托。

然后键盘显示栏,我需要更改栏颜色和按钮。

但我不知道如何设置。

有没有人可以帮助我?非常感谢。

【问题讨论】:

    标签: xcode button colors keyboard


    【解决方案1】:

    1.如果键盘将(确实)显示,则将键盘通知添加到否

    - (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(liftMainViewWhenKeybordAppears:) name:UIKeyboardWillChangeFrameNotification object:nil];
    

    }

    2.然后在liftMainViewWhenKeybordAppears:方法中,可以改变Bar Color和Button。

    - (void)liftMainViewWhenKeybordAppears:(NSNotification *)notice{
    
       yourBar.backgroundColor = [UIColor redColor];
       [yourButton setTitle:@"newTitle" forState:UIControlStateNormal];
    

    }

    3.删除通知

    - (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:YES];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
    

    }

    【讨论】:

      猜你喜欢
      • 2014-03-11
      • 2020-07-27
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-06
      相关资源
      最近更新 更多