iOS 自定义键盘ToolBar(与键盘的弹出、收起保持一致)
2024-08-25 23:18:35
1、监听键盘改变的通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
2、实现通知方法
/** * 给键盘的frame改变添加监听 * @param keyBoardWillChangeFrame: 监听方法 */ - (void)keyBoardWillChangeFrame:(NSNotification*)notification{ // 键盘显示\隐藏完毕的frame CGRect frame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; // 动画时间 CGFloat duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; if (frame.origin.y == JYEScreenHeight) { // 没有弹出键盘 [UIView animateWithDuration:duration animations:^{ self.toolBarView.transform = CGAffineTransformIdentity; }]; }else{ // 弹出键盘 // 工具条往上移动258 [UIView animateWithDuration:duration animations:^{ self.toolBarView.transform = CGAffineTransformMakeTranslation(, -frame.size.height-); }]; } }
最新文章
- JavaScript中数组去除重复
- Java cookie和session介绍与区别
- C++11 feature: move constructor
- [ZZ] Maxwell 架构
- EF扩展库(批量操作)
- java循环遍历类属性 get 和set值方法
- Js扩容
- 在WPF中将图片转换成3D图像并可以旋转
- C#编程(三十八)----------运算符
- 【译】Apache Flink Kafka consumer
- C#-流、存储
- Cygwin镜像使用
- 20155328 《Java程序设计》 实验二(Java面向对象程序设计) 实验报告
- DP---(POJ1159 POJ1458 POJ1141)
- GridView 基本使用
- make cmake catkin_make
- WPF设置全局快捷键
- python学习(十八) 程序打包
- Android开发:《Gradle Recipes for Android》阅读笔记(翻译)4.2——增加自定义task
- Delphi Runtime Library在哪里?