setNeedsLayout 和 setNeedsDisplay [英] setNeedsLayout and setNeedsDisplay

查看:23
本文介绍了setNeedsLayout 和 setNeedsDisplay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIView 方法 setNeedsLayoutsetNeedsDisplay 之间的真正区别是什么?

What is the real difference between UIView methods setNeedsLayout and setNeedsDisplay?

像往常一样,文档对此很模糊.

As usual documentation is foggy about this.

推荐答案

实际上文档对此非常清楚:

Actually the documentation is pretty clear about this:

当你想调整一个视图的子视图的布局时,在你的应用程序的主线程上调用这个方法.

Call this method on your application’s main thread when you want to adjust the layout of a view’s subviews.

  • setNeedsDisplay 将要求重绘您的视图(drawRect: 等).

  • setNeedsDisplay will call for a redraw of your view (drawRect:, etc).

    您可以使用此方法或 setNeedsDisplayInRect: 通知系统您的视图内容需要重绘.

    You can use this method or the setNeedsDisplayInRect: to notify the system that your view’s contents need to be redrawn.

  • 这篇关于setNeedsLayout 和 setNeedsDisplay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆