iOS知识点个人归纳总结--视图层相关

相关文章

基础

KeyWindow

能够接受非触摸和键盘事件时,就被认为是主窗口,而触摸事件则被投递到触摸位置的对应窗口。同一时刻只有一个窗口是主窗口。 (PS:这里相似的概念就是FirstResponder)

UIView/UIWindow/CALayer

UIView:一个管理屏幕上一块矩形可视化区域的对象。

  1. 渲染和动画
  2. 布局和子视图管理
  3. 事件处理

UIWindow:一种特殊的View(继承自UIView),通常App中只会有一个Window。

  1. 包含应用程序要显示的所有视图
  2. 分发事件到子视图中(触摸、旋转等)

CALayer:管理您提供的可视内容,但图层本身具有可设置的可视属性,例如背景颜色,边框和阴影。除了管理可视内容外,该图层还维护有关其内容几何的信息(例如其位置,大小和变换),用于在屏幕上显示该内容,同时还支持执行动画。

Frame与Bounds的区别

Frame:For layers, the frame rectangle is a computed property that is derived from the values in the bounds, anchorPoint and position properties.

Bounds:The origin and size of the layer in its own coordinate space.

事件传递/响应

关于这个有一篇文章讲的不错: www.jianshu.com/p/2e074db79…

概念/知识点:

事件:Apps can receive many different types of events, including touch events, motion events, remote-control events, and press events.

  • 事件源:UIKit分发到对应App的一个事件队列中.(App如何接到分发的事件的?Runloop)
  • 手势识别:如果app识别到这是一个手势,则直接调用对应的cancel方法打断回调,然后执行手势回调
  • 触摸事件处理方式:UIResponder方法重写直接处理/手势识别器
  • Application的事件_队列_(注意为什么是队列)
  • 如何确定最合适的响应事件的视图:1. hitTest:withEvent,2. pointInside
  • 响应者链条(nextResponder)

控制器View加载流程(LoadView)

If the view controller has an associated nib file, this method loads the view from the nib file. A view controller has an associated nib file if the nibName property returns a non-nil value, which occurs if the view controller was instantiated from a storyboard, if you explicitly assigned it a nib file using the initWithNibName:bundle: method, or if iOS finds a nib file in the app bundle with a name based on the view controller's class name. If the view controller does not have an associated nib file, this method creates a plain UIView object instead.

保持界面流畅性问题

大神经典好文:blog.ibireme.com/2015/11/12/…

概念/知识点:

  • VSync信号
  • CPU/GPU分工
  • 卡顿的原因是由于CPU/GPU工作量太大没有及时提交显示内容造成掉帧
  • CPU资源消耗的原因:对象的创建/修改/销毁,布局计算,AutoLayout(新版本已优化性能),大量文本宽高计算/渲染,图像解码/绘制
  • GPU资源消耗原因:纹理渲染,图层混合,离屏渲染
  • 性能优化技巧:预排版,预渲染,异步绘制,异步图片加载

转载于:https://juejin.im/post/5b4dbaf1e51d4518e3118392

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值