mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 19:03:52 +00:00
24 lines
736 B
Swift
24 lines
736 B
Swift
//
|
|
// Extensions.swift
|
|
// SAPTracker
|
|
//
|
|
// Created by computing on 11/11/14.
|
|
// Copyright (c) 2014 com.sap.sailing. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// http://stackoverflow.com/a/24263296
|
|
extension UIColor {
|
|
convenience init(red: Int, green: Int, blue: Int) {
|
|
assert(red >= 0 && red <= 255, "Invalid red component")
|
|
assert(green >= 0 && green <= 255, "Invalid green component")
|
|
assert(blue >= 0 && blue <= 255, "Invalid blue component")
|
|
|
|
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
|
|
}
|
|
|
|
convenience init(hex:Int) {
|
|
self.init(red:(hex >> 16) & 0xff, green:(hex >> 8) & 0xff, blue:hex & 0xff)
|
|
}
|
|
} |