iOS中 setNeedsDisplay和setNeedsLayout方法的不同
来源:互联网 发布:首席财务官 知乎 编辑:程序博客网 时间:2024/06/09 23:59
1、在Mac OS中NSWindow的父类是NSResponder,而在i OS 中UIWindow 的父类是UIVIew。程序一般只有一个窗口但是会又很多视图。
2、UIView的作用:描画和动画,视图负责对其所属的矩形区域描画、布局和子视图管理、事件处理、可以接收触摸事件、事件信息的载体、等等。
3、UIViewController 负责创建其管理的视图及在低内存的时候将他们从内存中移除。还为标准的系统行为进行响应。
4、layOutSubViews 可以在自己定制的视图中重载这个方法,用来调整子视图的尺寸和位置。
5、 UIView的setNeedsDisplay和setNeedsLayout方法。首先两个方法都是异步执行的。而setNeedsDisplay会调 用自动调用drawRect方法,这样可以拿到UIGraphicsGetCurrentCont
宗上所诉,setNeedsDisplay方便绘图,而layoutSubViews方便出来数据
1,UIView的setNeedsDisplay和setNeedsLayout方法
2、addSubview会触发layoutSubviews。
3、设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化。
4、滚动一个UIScrollView会触发layoutSubviews。
5、旋转Screen会触发父UIView上的layoutSubviews事件。
6、改变一个UIView大小的时候也会触发父UIView上的layoutSubviews事件。
3、通过设置contentMode属性值为UIViewContentModeRedraw。那么将在每次设置或更改frame的时候自动调用drawRect:。
4、直接调用setNeedsDisplay,或者setNeedsDisplayInRect:触发drawRect:,但是有个前提条件是rect不能为0。
以上1,2推荐;而3,4不提倡
2、若使用calayer绘图,只能在drawInContext:
3、若要实时画图,不能使用gestureRecognizer,只能使用touchbegan等方法来掉用setNeedsDisplay实时刷新屏幕
- iOS中 setNeedsDisplay和setNeedsLayout方法的不同
- IOS setNeedsDisplay 和 setNeedsLayout
- [IOS]setNeedsDisplay和setNeedsLayout
- iOS中setNeedsDisplay、setNeedsLayout的作用
- iOS-UIView常用的setNeedsDisplay和setNeedsLayout
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法调用
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法区别
- iOS UIView setNeedsDisplay和setNeedsLayout
- UIView中 setNeedsDisplay和setNeedsLayout
- setNeedsDisplay和setNeedsLayout的区别
- iOS学习之——UIView的setNeedsDisplay和setNeedsLayout方法
- iOS开发之UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
- IOS中UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout
- android中生成excel
- TCP/IP知识理解(下)
- DOM addClass MOveClass
- html disabled 和readonly,disabled 引起的form表单提交问题
- extjs基本属性
- iOS中 setNeedsDisplay和setNeedsLayout方法的不同
- markdowm
- teechart 用法
- python学习之数据类型(基本元素)
- 如何获取ResultSet的行数和列数
- 华盛顿大学--初探深度学习
- android HandlerThread源码分析
- 23种java设计模式之模板模式
- Shell基础