Ios 如何防止旋转和调整大小时子视图脱离superview
我将旋转并调整一个视图(UIImageView)的大小,这样它就不会离开SupervView。 所以我写了以下内容Ios 如何防止旋转和调整大小时子视图脱离superview,ios,Ios,我将旋转并调整一个视图(UIImageView)的大小,这样它就不会离开SupervView。 所以我写了以下内容 //rotating and resizing process //testing subview is in superview CGRect rect = subview.bounds; CGRect converted_rect = [subview convertRect:rect toView:subview.superview];
//rotating and resizing process
//testing subview is in superview
CGRect rect = subview.bounds;
CGRect converted_rect = [subview convertRect:rect toView:subview.superview];
if(!CGRectContainsRect(subview.superview.frame, converted_rect))
{
//restore proccess
}
但是我的代码无法阻止退出superview区域。如果使用情节提要,请选中superview属性检查器中的“剪辑子视图”框。如果不是,UIView有一个名为clipToBounds的属性,您可以将其设置为YES。两者都执行相同的操作,根据您的项目选择是使用情节提要还是编程方法。如果选中superview的“剪辑子视图”属性,则仅隐藏出superview的一部分子视图。无法阻止外出。