我写了这段代码来阻止UIImage
离开屏幕,但这只适用于左侧。我怎样才能让这些代码在右侧工作?
请注意,UIImage
由加速度计控制:
CGFloat leftOfWorld = 0.0f;
CGFloat minCenterX = leftOfWorld + (person.bounds.size.width / 2.0f);
person.center = CGPointMake(MAX(minCenterX, person.center.x), person.center.y);
答案 0 :(得分:0)
你走了:
CGFloat maxCenterX = self.view.frame.size.width - (person.bounds.size.width / 2.0f);
person.center = CGPointMake(MIN(maxCenterX, person.center.x), person.center.y);