Giter VIP home page Giter VIP logo

Comments (8)

ystsoi avatar ystsoi commented on May 12, 2024 6

I add the following method to ChromaColorPicker to solve the issue:

open override func layoutSubviews() {
    super.layoutSubviews()
    layout()
}

from chromacolorpicker.

Laptopmini avatar Laptopmini commented on May 12, 2024

After messing around some more with duplicate constraints (with one having lower priority), I figure out how to get the ColorPicker to layout all its subviews properly.

However, for the color picker to render properly during a screen rotation I had to override didRotateFromInterfaceOrientation and call .layout() within it.

from chromacolorpicker.

joncardasis avatar joncardasis commented on May 12, 2024

Apologies getting back so late to these issues. I had some problems with iOS calling some of its native layouts too often or multiple times. Since .layout() will redraw everything it can take some time and I'll look into a better way for the project to handle this without needing to override things. I'll also look at didRotateFromInterfaceOrientation - good point.

from chromacolorpicker.

ivanlares avatar ivanlares commented on May 12, 2024

Has this issue been solved ?
When I constraint the color picker, the interface doesn't seem to be drawn at all.

If I hardcode a frame value for the picker, the picker layout looks good.
I also tried calling layout().

I set the background color to red

simulator screen shot - iphone 5s - 2018-08-18 at 13 58 01

        let colorPicker = ChromaColorPicker()
        colorPicker.backgroundColor = .red
        colorPicker.translatesAutoresizingMaskIntoConstraints = false
        canvasView.addSubview(colorPicker)
        
        colorPicker.padding = 5
        colorPicker.stroke = 3
        colorPicker.hexLabel.textColor = UIColor.white
        
        colorPicker.widthAnchor.constraint(equalToConstant: 350).isActive = true
        colorPicker.heightAnchor.constraint(equalToConstant: 350).isActive = true
        colorPicker.centerXAnchor.constraint(equalTo: canvasView.centerXAnchor).isActive = true
        colorPicker.centerYAnchor.constraint(equalTo: canvasView.centerYAnchor).isActive  = true
        
        colorPicker.layout()

The solution that @ystsoi provided only works if the picker has a 1:1 ratio.
If you constrain the picker to a view that is not a square the layout will look stretched out.

from chromacolorpicker.

wdcurry avatar wdcurry commented on May 12, 2024

It is still a tad messy. I have a 1:1 ration and see the center circle and slider to be offset. So close to being an amazing repo. I have augmented the protocol to give me more data as well.

from chromacolorpicker.

joncardasis avatar joncardasis commented on May 12, 2024

Hey, everyone. It's been a while since I've been able to look at this project. I am merging the change @ystsoi mentioned above which is what should have been done originally in this project. As the picker is currently built, it will need a 1:1 ratio for its proportions. I plan to rid this dependency in a future update.

NOTE:
I am starting a rewrite of a number of features on this project for better customizability and ease-of-use. If you have any suggestions you'd like to see in the evolution of this project, please open a new issue with the EVOLUTION REQUEST label.

from chromacolorpicker.

wdcurry avatar wdcurry commented on May 12, 2024

Currently adjustToColor loses any inbound alpha. This is not a desirable situation.

from chromacolorpicker.

joncardasis avatar joncardasis commented on May 12, 2024

@wdcurry I agree and this is planned to be addressed in the rewrite of this component to hold this alpha value.

from chromacolorpicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.