// 监听键盘通知
NotificationCenter.default.addObserver(self, selector: #selector(ComposeViewController.keyboardWillChangeFrame(note:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
    //监听键盘的事件
func keyboardWillChangeFrame(note: Notification) { print(note.userInfo ?? "")
// 1.获取动画执行的时间
let duration = note.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as! TimeInterval // 2.获取键盘最终 Y值
let endFrame = (note.userInfo?[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let y = endFrame.origin.y //计算工具栏距离底部的间距
let margin = UIScreen.main.bounds.height - y
print(margin)
// 更新约束,执行动画
toolBarBottom.snp.updateConstraints { (make) in
make.left.equalTo()
make.right.equalTo()
make.height.equalTo()
make.bottom.equalTo(-margin)
}
UIView.animate(withDuration: duration) {
self.view.layoutIfNeeded()
}
}

最新文章

  1. git--- 拉取代码
  2. Spring解析实践
  3. 【BZOJ1003】1003: [ZJOI2006]物流运输trans SPFA+DP
  4. Nim教程【二】
  5. Vmware9.0打开早期版本报错:this virtual machine’s policies are too old to be run by this version of vmware workstation”
  6. Log4net - 规则简介(续)
  7. laravel 心得
  8. 官网下载qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe。封装好了Qt libraries、Qt Creator。只需要这一个可执行程序就好了。
  9. (简单) POJ 1562 Oil Deposits,BFS。
  10. Weex系列一、构建Weex工程
  11. 课堂作业 泛型类-Bag
  12. windows update error 0x8024401c
  13. jmeter的安装和配置
  14. 4.6Python数据处理篇之Matplotlib系列(六)---plt.hist()与plt.hist2d()直方图
  15. 【官档整理】Visual Studio 2017 VS2017 中文离线安装包下载
  16. Xcode 常用代码段
  17. Word 2017 快捷键
  18. Spring 3.1 M1: Unified Property Management(转)
  19. net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting head
  20. json 模块的基本使用学习

热门文章

  1. javacpp-FFmpeg系列补充:FFmpeg拉流截图实现在线演示demo(视频截图并返回base64图像,支持jpg/png/gif/bmp等多种格式)
  2. [原创]如何解决IE10下CkEditor报 --- SCRIPT5007: 无法获取未定义或 null 引用的属性“toLowerCase”
  3. Mysql 创建存储过程 更新表
  4. 好文章!转载嵌入式LINUX
  5. libvirtError: 无效参数:could not find capabilities for domaintype=kvm
  6. 创建oracle数据库图示(一步一步教你安装oracle)
  7. 慕课网java就业班级
  8. MS SQL PIVOT数据透视表
  9. 蜂窝网络TDOA定位方法的Fang算法研究及仿真纠错
  10. AS负责人说不必用Kotlin重写,但OkHttp拿Kotlin重写了一遍,就发了OkHttp 4.0!