Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
UIView方法setNeedsLayout和之间的真正区别是什么setNeedsDisplay?
UIView
setNeedsLayout
setNeedsDisplay
像往常一样,文档对此很模糊。
实际上,文档对此非常清楚:
setNeedsLayout将布局子视图
当您想要调整视图的子视图的布局时,请在应用程序的主线程上调用此方法。
setNeedsDisplay将要求重绘您的视图(drawRect:等)。
drawRect:
您可以使用此方法或 setNeedsDisplayInRect: 通知系统您的视图内容需要重绘。