New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color Crashing Ring #11
Comments
I just have two different UIViews set as MKRingProgressview that causes the crash. Not inside of one another. |
It is crashing on this line:
in the MKGradientGenerator.swift file |
It looks like the Cyan color is crashing the ring actually |
Hi @Treverr! |
This is due to the wide range of color from iOS10. Each CGColor component can have value bigger than 1.0 or smaller than 0.0. If you are ok with ignoring the wide range of color, you can use this initializer in fileprivate init(_ color: CGColor) {
let c = color.components?.map({ (v) -> CGFloat in
if v < 0.0 {
return 0.0
}else if v > 1.0 {
return 1.0
} else {
return v
}
})
switch color.numberOfComponents {
case 2:
self.init(r: UInt8((c?[0])! * 0xff), g: UInt8((c?[0])! * 0xff), b: UInt8((c?[0])! * 0xff), a: UInt8((c?[1])! * 0xff))
case 4:
self.init(r: UInt8((c?[0])! * 0xff), g: UInt8((c?[1])! * 0xff), b: UInt8((c?[2])! * 0xff), a: UInt8((c?[3])! * 0xff))
default:
self.init()
}
} |
@maxkonovalov @purpleblues solution fixes that issue. Could you add it into the code and cocoa pods? |
…omponent values are within the 0.0 -> 1.0 interval Using @purpleblues’s suggestion maxkonovalov#11 (comment)
@Treverr @purpleblues @jendaz Please note that the current fix may cause some colors to be displayed incorrectly on wide-gamut screens due to clamped values. Cheers! |
Hello,
I have two rings inside of a standard UIViewController, and when I add the second one it says
"MKRingProgressView was compiled with optimization - stepping may behave oddly; variables may not be available."
When the app crashes.
Also, I am getting a error: IB Designables: Failed to render and update auto layout status for HomeViewController (h2x-s1-kZZ): The agent crashed
Any idea what could be causing this?
The text was updated successfully, but these errors were encountered: