-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Labels
Description
Using UIImageColor to get the dominant color on the photo to set background accordingly but when I do try the following
WebImage(url: URL("https://img-9gag-fun.9cache.com/photo/aQ1GWV8_700b.jpg"))
.onSuccess { image, cacheType in
image.getColors(quality: .lowest) {colors in
guard let colors = colors else { return }
if (colors.background.toHexString() != "#000000") {
self.cardBackground = colors.background
} else {
self.cardBackground = UIColor(red: 0.130, green: 0.130, blue: 0.130, alpha: 1.0)
}
self.cardHeading = colors.primary
self.cardDesc = colors.secondary
}
}
Before I using WebImage I had
Image.init(uiImage: imageData)
.onAppear(perform: {
image.getColors(quality: .lowest) { colors in
guard let colors = colors else { return }
if (colors.background.toHexString() != "#000000") {
self.cardBackground = colors.background
} else {
self.cardBackground = UIColor(red: 0.130, green: 0.130, blue: 0.130, alpha: 1.0)
}
self.cardHeading = colors.primary
self.cardDesc = colors.secondary
}
})