0

我编写了这段代码来阻止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);
4

1 回答 1

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);
于 2013-04-12T12:28:38.233 回答