calculate text overlay color

This commit is contained in:
Ryan Nystrom
2017-05-20 17:10:10 -04:00
parent c65452f081
commit 83924987ff
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
//
// UIColor+Overlay.swift
// Freetime
//
// Created by Ryan Nystrom on 5/20/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
extension UIColor {
var textOverlayColor: UIColor? {
guard let componentColors = cgColor.components else { return nil }
let brightness = (componentColors[0]*299 + componentColors[1]*587 + componentColors[2]*114) / 1000.0
return brightness < 0.5 ? .white : .black
}
}

View File

@@ -74,6 +74,7 @@
29A4769A1ED0AD09005D0953 /* IssueLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A476991ED0AD09005D0953 /* IssueLabelsModel.swift */; };
29A4769C1ED0DEE2005D0953 /* IssueLabelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769B1ED0DEE2005D0953 /* IssueLabelCell.swift */; };
29A4769E1ED0E083005D0953 /* Label+IGListDiffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769D1ED0E083005D0953 /* Label+IGListDiffable.swift */; };
29A476A01ED0E6C6005D0953 /* UIColor+Overlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A4769F1ED0E6C6005D0953 /* UIColor+Overlay.swift */; };
29C0E7071ECBC6C50051D756 /* GithubClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C0E7061ECBC6C50051D756 /* GithubClient.swift */; };
29C167671ECA005500439D62 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C167661ECA005500439D62 /* Strings.swift */; };
29C167691ECA016500439D62 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C167681ECA016500439D62 /* EmptyView.swift */; };
@@ -210,6 +211,7 @@
29A476991ED0AD09005D0953 /* IssueLabelsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueLabelsModel.swift; sourceTree = "<group>"; };
29A4769B1ED0DEE2005D0953 /* IssueLabelCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueLabelCell.swift; sourceTree = "<group>"; };
29A4769D1ED0E083005D0953 /* Label+IGListDiffable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Label+IGListDiffable.swift"; sourceTree = "<group>"; };
29A4769F1ED0E6C6005D0953 /* UIColor+Overlay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Overlay.swift"; sourceTree = "<group>"; };
29C0E7061ECBC6C50051D756 /* GithubClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GithubClient.swift; sourceTree = "<group>"; };
29C167661ECA005500439D62 /* Strings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Strings.swift; sourceTree = "<group>"; };
29C167681ECA016500439D62 /* EmptyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
@@ -434,6 +436,7 @@
29A195011EC66B8B00C3E289 /* UIColor+Hex.swift */,
298BA08E1EC90FEE00B01946 /* UIView+BottomBorder.swift */,
29A4768D1ED07A23005D0953 /* DateDetailsFormatter.swift */,
29A4769F1ED0E6C6005D0953 /* UIColor+Overlay.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -783,6 +786,7 @@
29C1677F1ECA1D7300439D62 /* SettingsViewController.swift in Sources */,
298BA08B1EC9031E00B01946 /* RepoNotifications+Notification.swift in Sources */,
29C167821ECA4B1C00439D62 /* IssueEvent.swift in Sources */,
29A476A01ED0E6C6005D0953 /* UIColor+Overlay.swift in Sources */,
29C9FDD61EC65FEE00EE3A52 /* Status.swift in Sources */,
29316DB51ECC7DEB007CAE3F /* CenteredButtonCell.swift in Sources */,
293E147D1ECFE8CF001FB0EB /* IssueCommentModel.swift in Sources */,