If with CGPointEqualToPoint do not work

≡放荡痞女 提交于 2019-12-06 03:57:16

The implementation of CGPointEqualToPoint is

CG_INLINE bool __CGPointEqualToPoint(CGPoint point1, CGPoint point2)
{
    return point1.x == point2.x && point1.y == point2.y;
}

... so coordinates have to be absolutely equal to return true.

This is not always the case with CGFloat types, even if pixels seem to be aligned. There might be tiny errors resulting from the way you calculate them in your animation or game simulation code.

You could try to round the values before comparing them or allow for a small deviation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!