Color from Green to Red with Percentage
问题 i am trying to create a custom UIColor from Green to Red depends on a Percentage Value, but i have no idea how can i do something like that? Any ideas? 回答1: Something along these lines should work, if you just want a linear mix: func mixGreenAndRed(greenAmount: Float) -> UIColor { return UIColor(red: (1.0 - greenAmount), green: greenAmount, blue: 0.0, alpha: 1.0) } That one will blend through RGB (0.5, 0.5, 0), though—a kind of ugly orange—so you might want to do this instead, which will just