gizmosachin / ColorSlider

🎨 Snapchat-style color picker in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autolayout issues?

sabiland opened this issue · comments

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

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))
    }