UIView框架更改通知 [英] UIView frame change Notification

查看:114
本文介绍了UIView框架更改通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当UIView的帧或边界发生变化时是否有任何通知?每当UIView的帧发生变化时,我需要计算并设置其自定义子视图的帧,以使其方面适合超级视图。

Is there any notification when frame or bounds of UIView changes? Whenever frame of a UIView changes, I need to calculate and set the frame of its custom subview so that it aspect fits in the superview.

NSView为此目的通知NSViewFrameDidChangeNotfication。为什么UIView不存在?

NSView has the notification NSViewFrameDidChangeNotfication for the purpose. Why is this not there for UIView?

推荐答案

没有通知。你可以将UIView子类化为覆盖 layoutSubviews ,直接进行布局或发送必要的通知。

There is no notification. You can subclass UIView to override layoutSubviews, to either do the layout directly or send the necessary notification.

你有没有尝试设置适当的 autoresizingMask ,以便子视图自动调整大小?

Have you tried setting an appropriate autoresizingMask so the subview gets resized automatically?

这篇关于UIView框架更改通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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