setNeedsDisplay 和 setNeedsLayout-b
2016-05-30 16:08
393 查看
setNeedsDisplay:
Marks the receiver’s entire bounds rectangle as needing to be redrawn.drawRect:
This method is called when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call thesetNeedsDisplayor
setNeedsDisplayInRect:method instead.
setNeedsLayout:
Invalidates the current layout of the receiver and triggers a layout update during the next update cycle.layoutIfNeeded
Use this method to force the layout of subviews before drawing.Lays out the subviews immediately.layoutSubviews:
You should not call this method directly. If you want to force a layout update, call thesetNeedsLayout method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call thelayoutIfNeeded method.总之 你要是排布 子视图 就在layoutSubviews:
你要是画一些东西 就在drawRect:
相关文章推荐
- MAC使用Tip (terminal,adb,shell)
- 一天一个linux命令(3):实用小工具
- int 转 string
- mac 删除文件夹里所有的.svn文件
- 创建线程的两种方法
- CSS 绝对定位与相对定位
- boost裁剪和编译
- Delphi“尚未调用CoInitialize”解决方法
- ajax简单html页面内容获取
- 计时器
- 图的存储及遍历 深度遍历和广度遍历 C++代码实现
- 优秀ASP.NET程序员修炼之路
- C++ VS2012 内存泄露检测
- Android的px、dp和sp
- HTML 5 Web 存储
- Microsoft Visual Studio 2012常用快捷键
- c++ 赋值操作符的返回值
- ios 中生成随机数
- GPS坐标互转:WGS-84(GPS)、GCJ-02(Google地图)、BD-09(百度地图)
- nodejs那些事