Comments (4)
I modified the code to get it to work but it doesn't matter as I still can't use the colour asset stuff with old versions of ios. It works fine if you do it in code but not if you use storyboards to set the colours. Bugger!
Thanks anyway.
from colorassetcatalog.
Odd, I wouldn't expect those component values to be Strings! They should always be numerical (without quotes) in the JSON. Did you modify or generate that JSON manually?
from colorassetcatalog.
To reproduce, use the latest version of the Xcode. It saves the values of the colours as strings instead of doubles.
The decoding failure relates to this issue inside swift:
https://bugs.swift.org/browse/SR-5249
Modification to the ColorAssetCatalog.swift that would make it usable again is:
extension ColorAsset.Color {
struct Components: Decodable {
var alpha: CGFloat = 1
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var white: CGFloat? {
didSet {
guard let white = white else { return }
red = white
green = white
blue = white
}
}
enum CodingKeys: String, CodingKey {
case alpha
case red
case green
case blue
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
alpha = CGFloat(Double(try values.decode(String.self, forKey: .alpha))!)
red = CGFloat(Double(try values.decode(String.self, forKey: .red))!)
green = CGFloat(Double(try values.decode(String.self, forKey: .green))!)
blue = CGFloat(Double(try values.decode(String.self, forKey: .blue))!)
}
}
}
from colorassetcatalog.
Thank you @adamwidera1978!
I've made the change. Will publish a new version to Cocoapods when I get a chance later.
from colorassetcatalog.
Related Issues (9)
- ColorAssetManager is inaccessible HOT 1
- Can't use with NSAttributedString in iOS 10 HOT 1
- Can't find asset Color in framework bundle HOT 1
- What Color Space to use? HOT 1
- Interface builder options HOT 1
- 8-bit Hexadecimal format not working
- Add support for Swift 4.2 please HOT 1
- iOS9 and 10 backward compatibility not working HOT 3
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 colorassetcatalog.