[ABANDONED] Mastodon iOS client.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
527 B

6 years ago
  1. //
  2. // UIColor+HexString.swift
  3. // elpha-ios
  4. //
  5. // Created by Dwayne Harris on 11/6/18.
  6. // Copyright © 2018 Elpha. All rights reserved.
  7. //
  8. import UIKit
  9. extension UIColor {
  10. func hexString() -> String {
  11. var r: CGFloat = 0
  12. var g: CGFloat = 0
  13. var b: CGFloat = 0
  14. var a: CGFloat = 0
  15. getRed(&r, green: &g, blue: &b, alpha: &a)
  16. let rgb: Int = (Int)(r * 255) << 16 | (Int)(g * 255) << 8 | (Int)(b * 255) << 0
  17. return String(format: "#%06x", rgb)
  18. }
  19. }