如果有视图,如何确定其框架是否包含在可见屏幕中?
我目前有这个,但是它很粗略,根本没有鲁棒性。
var newPoint = (this.ConvertPointFromView(new PointF(newX, newY), UIApplication.SharedApplication.KeyWindow.RootViewController.View));
if (newPoint.X + _infoBox.Frame.Width > UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame.Width
|| newPoint.Y + _infoBox.Frame.Height + _glass.Frame.Height > UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame.Height)
{
//.....
}
要比较一个rect是否完全在seconf rect内部,可以使用CGRectContainsRect(rect2,rect1))函数
像这样:CGRectContainsRect([[UIScreen mainScreen] bounds],Infobox.frame)
我不太喜欢快速语法,但是转换起来应该很容易。
编辑:使用convertRect获取屏幕坐标中的信息框。将nil作为view:参数传递。[信息框convertRect:infobox.bounds视图:无]
来自手机。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句