Comments (8)
I add the following method to ChromaColorPicker to solve the issue:
open override func layoutSubviews() {
super.layoutSubviews()
layout()
}
from chromacolorpicker.
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.
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.
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
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.
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.
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.
Currently adjustToColor loses any inbound alpha. This is not a desirable situation.
from chromacolorpicker.
@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)
- 3 Swift Compiler Warnings with XCode 10 beta 6 HOT 2
- adjustToColor() doesn't play nicely with supportsShadesOfGray HOT 1
- Swift 5 Compile Errors HOT 2
- Xcode 10.2 compiler failed, I can't build my project :( HOT 9
- Input color value selection color
- Is it possible to select a color by clicking? HOT 2
- color picker handle HOT 3
- Alpha color scroll not working smoothly
- ChromaColorPicker and ChromaBrightnessSlider call events twice HOT 1
- Change handle of place HOT 1
- Autolayout issue HOT 1
- Adding option for vertical brightness slider and custom brightness slider handle shape HOT 1
- No way to remove handles or update their color position in code HOT 1
- currentHandle not initialized? HOT 4
- Swift Package Manager Error
- iOS 14 issues in modal
- Crashes in iOS 9
- How could I add event to the home handle?
- Suggestion: set default handle
- Support color extraction for pictures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chromacolorpicker.