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
extension UIColor { | |
/** | |
convert rgb to UIColor object | |
*/ | |
class func color(color: UInt32, alpha : CGFloat = 1.0) -> UIColor { | |
let r = CGFloat((color & 0xFF0000) >> 16) / 255.0 | |
let g = CGFloat((color & 0x00FF00) >> 8) / 255.0 | |
let b = CGFloat(color & 0x0000FF) / 255.0 | |
return UIColor(red:r,green:g,blue:b,alpha:alpha) | |
} |
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
/** | |
adapt to enum which is Int Raw Value. | |
It make enum return the array of cases | |
#### Example | |
``` | |
enum SomeEnum: IntRawValueEnumerable { | |
case AAA | |
case BBB | |
} |
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
/** | |
#### Example | |
if case Regex("^regular\s.+$") = "regular expression" { | |
return true | |
} | |
switch "regular expression" { | |
case Regex("^regular\s.+$"): | |
print("match ^regular\s.+$") | |
case Regex("^regurar\s.+$"): |
NewerOlder