ios - 在 UIView 上调用 setFrame 之后是否必须显式调用 setNeedsDisplay?

标签 ios uiview

UIView 上调用 setFrame 后是否必须显式调用 setNeedsDisplay 如下例所示?

view1.frame = frame;
[view1 setNeedsDisplay];

[view2 setFrame:frame];

最佳答案

简短回答:

当你需要方法drawRect被调用时你调用setNeedsDisplay,并且根据UIView Class Reference.-

Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.

关于ios - 在 UIView 上调用 setFrame 之后是否必须显式调用 setNeedsDisplay?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15959979/

相关文章:

iphone - 无法从 UIViewController 加载 xib 文件

ios - 从 UIView 子类访问属性

ios - 用键盘移动屏幕

ios - Mantle - 将字符串转换为枚举值

iphone - 当我更改 Localizable.strings (en) 时,另一个 Localizable.strings (ru) 也会更改

ios - 选择上方 UITextField 时向下滚动 UIScrollView

ios - 具有同步计数线程的 UIView 动画

ios - 在 Swift 中,如何使用自动布局为 UIView 设置动画,如页面滑入?

ios - 更改 View 后 UITabBar iAd 横幅未正确加载

ios - 在 iOS 中访问音频输出