MIN MAX 控制值在一定范围区间

将值控制在0~0.999之间
MIN(0.999, MAX(0, timeoffset - x))
MIN 让值不大于0.999,MAX让值不小于0.

-(void)pan:(UIPanGestureRecognizer * )pan
{
    CGFloat x =[pan translationInView:self.view].x;
    x /= 200.0;
    CFTimeInterval timeOffset = self.doorLayer.timeOffset;
    timeoffset = MIN(0.999, MAX(0, timeoffset - x));
    self.doorLayer.timeOffset = timeOffset;
    [pan setTranslation:CGPointZero inView:self.view];
}
static float randomFloatBetween(float from, float to)
{
    return from + ((float)rand()/(float)RAND_MAX) * (to - from);
}

你可能感兴趣的:(MIN MAX 控制值在一定范围区间)