Guest User

Untitled

a guest
Dec 10th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. //
  2. // UIColorsExtensions.swift
  3. // PriceBar
  4. //
  5. // Created by Leonid Nifantyev on 4/1/18.
  6. // Copyright © 2018 LionLife. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import UIKit
  11.  
  12. public enum Color {
  13. static var pomegranate: UIColor = UIColor.simpleColor(red: 233.0, green: 79.0, blue: 21.0)
  14. static var neonCarrot: UIColor = UIColor.simpleColor(red: 255.0, green: 146.0, blue: 46.0)
  15. static var dustyGray: UIColor = UIColor.simpleColor(red: 151, green: 151, blue: 151)
  16. static var alto: UIColor = UIColor.simpleColor(red: 216, green: 216, blue: 216)
  17. static var petiteOrchid: UIColor = UIColor.simpleColor(red: 223, green: 142.0, blue: 142.0)
  18. static var jaggedIce: UIColor = UIColor.simpleColor(red: 200, green: 231, blue: 238)
  19. static var havelockBlue: UIColor = UIColor(rgb: 0x4A90E2)
  20. static var atlantis: UIColor = UIColor.simpleColor(red: 131, green: 200, blue: 60)
  21. static var feijoaGreen: UIColor = UIColor(rgb: 0xB0DB84)
  22. }
  23.  
  24. extension UIColor {
  25. static func simpleColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor {
  26. return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha)
  27. }
  28.  
  29. convenience init(red: Int, green: Int, blue: Int) {
  30. assert(red >= 0 && red <= 255, "Invalid red component")
  31. assert(green >= 0 && green <= 255, "Invalid green component")
  32. assert(blue >= 0 && blue <= 255, "Invalid blue component")
  33.  
  34. self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
  35. }
  36.  
  37. convenience init(rgb: Int) {
  38. self.init(
  39. red: (rgb >> 16) & 0xFF,
  40. green: (rgb >> 8) & 0xFF,
  41. blue: rgb & 0xFF
  42. )
  43. }
  44. }
Add Comment
Please, Sign In to add comment