ios setNeedsLayout 和 setNeedsDisplay
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14506968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
setNeedsLayout and setNeedsDisplay
提问by DuckDucking
What is the real difference between UIView
methods setNeedsLayout
and setNeedsDisplay
?
UIView
方法setNeedsLayout
和之间的真正区别是什么setNeedsDisplay
?
As usual documentation is foggy about this.
像往常一样,文档对此很模糊。
回答by Joris Kluivers
Actually the documentation is pretty clear about this:
实际上,文档对此非常清楚:
setNeedsLayoutwill layout subviews
Call this method on your application's main thread when you want to adjust the layout of a view's subviews.
setNeedsDisplaywill call for a redraw of your view (
drawRect:
, etc).You can use this method or the setNeedsDisplayInRect: to notify the system that your view's contents need to be redrawn.
setNeedsLayout将布局子视图
当您想要调整视图子视图的布局时,请在应用程序的主线程上调用此方法。
setNeedsDisplay将要求重绘您的视图(
drawRect:
等)。您可以使用此方法或 setNeedsDisplayInRect: 通知系统您的视图内容需要重绘。