gizmosachin / ColorSlider

🎨 Snapchat-style color picker in Swift
MIT License
288 stars 53 forks source link

Autolayout issues? #26

Open sabiland opened 6 years ago

sabiland commented 6 years ago

On iPad after rotations this happens (look at the image). Is there an option to force re-layout ColorSlider? I tried layoutIfNeeded, etc. But no success Preview UIView is not correctly repositioned upon device rotations.

The easiest way to reproduce it is like this:

1) Make ColorSlider Autolayouted (so the width is different for specific device orientation) 2) Rotate device (iPhone or iPad) 3) Preview UIView is not correctly repositioned

sabiland commented 6 years ago

I have temporarily fixe this with adding this function to ColorSlider and calling it after device rotate.

public func forceRepositionPreviewView()
    {
        let sliderProgress = gradientView.calculateSliderProgress(for: internalColor)
        centerPreview(at: CGPoint(x: sliderProgress * bounds.width, y: sliderProgress * bounds.height))
    }