This file contains hidden or 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 UIKit | |
extension UIColor { | |
/** | |
The rgba string representation of color with alpha of the form #RRGGBBAA/#RRGGBB. | |
- parameter rgba: String value, which may or may not start from # sign. | |
*/ | |
public convenience init?(rgba: String, defaultAlpha: CGFloat = 1) { | |
// We migth want to trim the string first from spaces, etc. | |
let rgbaStripped = rgba.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) |
This file contains hidden or 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
func minsOf(pairs: [(Int, Int)]) -> (Int, Int) { | |
return pairs.reduce((Int.max, Int.max)) { | |
(($0.0 < $1.0) ? $0.0 : $1.0, (($0.1 < $1.1) ? $0.1 : $1.1)) | |
} | |
} | |
func maxsOf(pairs: [(Int, Int)]) -> (Int, Int) { | |
return pairs.reduce((Int.min, Int.min)) { | |
(($0.0 > $1.0) ? $0.0 : $1.0, (($0.1 > $1.1) ? $0.1 : $1.1)) | |
} |