hayashi311 / Color-Picker-for-iOS

Colorful: iOS color picker built with Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make HRBrightnessSlider Animated When Moving

GabeRoze opened this issue · comments

It looks a lot better. I've added this to my current project. Played around with all the animation duration, this works the best.

  • (void)updateCursor {
    CGFloat brightnessCursorX = (1.0f - (self.brightness.floatValue - self.brightnessLowerLimit.floatValue) / (1.0f - self.brightnessLowerLimit.floatValue));
    if (brightnessCursorX < 0) {
    return;
    }
    CGPoint point = CGPointMake(brightnessCursorX * _controlFrame.size.width + _controlFrame.origin.x, _brightnessCursor.center.y);
    [UIView animateWithDuration:0.1
    delay:0
    options:UIViewAnimationOptionCurveEaseIn
    animations:^
    {
    _brightnessCursor.center = point;
    _brightnessCursor.color = self.color;
    }
    completion:^(BOOL finished)
    {

        }];
    

    }