This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your preview struct just add | |
// `darkThemePreview()` to the view you're previewing! | |
import SwiftUI | |
extension View { | |
func darkThemePreview() -> some View { | |
Group { | |
self | |
self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// color - source color, which is must be replaced | |
// withColor - target color | |
// tolerance - value in range from 0 to 1 | |
func replaceColor(color: UIColor, withColor: UIColor, image: UIImage, tolerance: CGFloat) -> UIImage { | |
// This function expects to get source color(color which is supposed to be replaced) | |
// and target color in RGBA color space, hence we expect to get 4 color components: r, g, b, a | |
assert(color.cgColor.numberOfComponents == 4 && withColor.cgColor.numberOfComponents == 4, | |
"Must be RGBA colorspace") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import GameController | |
protocol ControllerAnimatable: class { | |
var controller: GCController { get } | |
} | |
extension ControllerAnimatable { | |
/// Animates controller light color to a specified color of `GCColor` type. | |
/// - Parameters: |