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 the setNeedsDisplayorsetNeedsDisplayInRect: 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:

setNeedsDisplay 和 setNeedsLayout-b的更多相关文章

  1. UIView的setNeedsDisplay和setNeedsLayout

    1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

  2. setNeedsDisplay,setNeedsLayout

    UIView的setNeedsDisplay和setNeedsLayout方法.首先两个方法都是异步执行的.setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到UIGraph ...

  3. setNeedsDisplay和setNeedsLayout

    1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

  4. UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout

    1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

  5. 【转】 UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout

    原文:http://blog.sina.com.cn/s/blog_923fdd9b0101b2b4.html 1.在Mac OS中NSWindow的父类是NSResponder,而在iOS 中UIW ...

  6. iOS UIView常用的一些方法setNeedsDisplay和setNeedsLayout 区别

    1.UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

  7. UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout

    UIview需要知道的一些事情:setNeedsDisplay.setNeedsLayout 1.在Mac OS中NSWindow的父类是NSResponder,而在i OS 中UIWindow 的父 ...

  8. UIView常用的一些方法setNeedsDisplay和setNeedsLayout

    1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

  9. setNeedsDisplay和setNeedsLayout方法

    参考:https://blog.csdn.net/sunnyboy9/article/details/51458401 . UIView的setNeedsDisplay和setNeedsLayout方 ...

  10. UIView之setNeedsDisplay与drawRect 和 setNeedsLayout与layoutSubViews

    1.UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UI ...

随机推荐

  1. windows 批量执行命令的脚本

    因为老板一个电话,我的国庆节就没了....,老板要我写个东西,能批量执行500台windows的命令并返回结果,虽然完成以后是非常的简单,但是因为我走了很多弯路,一开始想用powershell来写,后 ...

  2. MyBatis(4):动态SQL

    什么是动态SQL MyBatis的一个强大特性之一通常是它的动态SQL能力.如果你有使用JDBC或其他相似框架的经验,你就明白条件串联SQL字符串在一起是多么地痛苦,确保不能忘了空格或者在列表的最后的 ...

  3. 怎样把redis编译为库,挪为己用?

    其实这是个伪命题.因为只要正常编译redis,那么在 /deps/hiredis/ 目录下就会生成动态库文件 libhiredis.so. 为了便于学习redis源码,编写一些测试程序,并进行单步跟踪 ...

  4. linux 发邮件

      一. centos yum 安装 1. yum install mailx vim  /etc/nail.rc 添加网易163邮箱开放的需要认证的smtp服务器: set from=USER@16 ...

  5. 对于数组(字符串)slice方法的总结

    数组(字符串)使用slice方法的目的就是截取目标数组(字符串),通俗的来讲就是截取想要的.网上有很多slice方法的实例加以说明,在此主要是从特殊到一般对此方法进行了总结. 先说总结的方法,再看下面 ...

  6. ld: 18 duplicate symbols for architecture i386 .linker command failed with exit code 1 (use -v to see invocation)_

    昨天被linker这个错误卡了一个小时!!!各种办法都试了 是导入第三方的问题 .. 网上说 要把所有的.m文件导入  但是我下载的微博SDK根本不关事..后来 大概知道是导入了多个相同的文件... ...

  7. Macos Coco2d-x Android开发

    1. 在装好环境 2. cocos new [-h] [-p PACKAGE_NAME] -l {cpp,lua,js} [-d DIRECTORY] [-t TEMPLATE_NAME] [--io ...

  8. python-增删改查

    ###增删改查 names = ["zhangding","wangxu","wudong","cheng"] #增 n ...

  9. HTML5 微信二维码提示框

    这是一个js的小案例,主要效果是显示一个微信二维码的提示框,非常简单实用. 源码如下: JS部分 <script src="js/jquery-1.8.3.min.js"&g ...

  10. http方法

    http method(方法):1.get 从服务器获取资源2.post 向服务器发送资源3.put 向服务器推送资源4.delete 告诉服务器删除某个资源5.head 告诉服务器返回数据时不需要返 ...