Skip to content

Instantly share code, notes, and snippets.

@tatey
Created September 20, 2015 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatey/e3bad737dc1f8a8196aa to your computer and use it in GitHub Desktop.
Save tatey/e3bad737dc1f8a8196aa to your computer and use it in GitHub Desktop.
import UIKit
class Style {
static let tableCellInset: CGFloat = 15.0
}
class StyleColor {
static let primaryBackgroundColor = UIColor.blackColor()
static let primaryTextColor = UIColor.whiteColor()
static let secondaryTextColor = UIColor(red: 0.45, green: 0.45, blue: 0.45, alpha: 1)
static let pointerColor = UIColor(red: 0.992, green: 0, blue: 0.075, alpha: 1)
static let tintColor = UIColor(red: 0, green: 0.67, blue: 0.87, alpha: 1)
static let barStyle: UIBarStyle = .Black
static let tableViewDividerColor = UIColor(red: 0.177, green: 0.177, blue: 0.177, alpha: 1)
static let tableViewSeparatorColor = UIColor(red: 0.18, green: 0.18, blue: 0.18, alpha: 1)
static let tableViewSelectedColor = UIColor(red: 0.22, green: 0.22, blue: 0.22, alpha: 1)
static let tableViewIndicatorStyle: UIScrollViewIndicatorStyle = .White
}
class StyleFont {
private static let bodyDefaultCategorySize: CGFloat = 18
private static let bodyCategorySizes: [String: CGFloat] = [
UIContentSizeCategoryExtraSmall: 15,
UIContentSizeCategorySmall: 16,
UIContentSizeCategoryMedium: 17,
UIContentSizeCategoryLarge: bodyDefaultCategorySize,
UIContentSizeCategoryExtraLarge: 19,
UIContentSizeCategoryExtraExtraLarge: 20,
UIContentSizeCategoryExtraExtraExtraLarge: 21,
UIContentSizeCategoryAccessibilityMedium: 22,
UIContentSizeCategoryAccessibilityLarge: 23,
UIContentSizeCategoryAccessibilityExtraLarge: 24,
UIContentSizeCategoryAccessibilityExtraExtraLarge: 25,
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: 26,
]
private static let tableCellTitleDefaultCategorySize: CGFloat = 17
private static let tableCellTitleCategorySizes: [String: CGFloat] = [
UIContentSizeCategoryExtraSmall: 14,
UIContentSizeCategorySmall: 15,
UIContentSizeCategoryMedium: 16,
UIContentSizeCategoryLarge: tableCellTitleDefaultCategorySize,
UIContentSizeCategoryExtraLarge: 18,
UIContentSizeCategoryExtraExtraLarge: 19,
UIContentSizeCategoryExtraExtraExtraLarge: 20,
UIContentSizeCategoryAccessibilityMedium: 21,
UIContentSizeCategoryAccessibilityLarge: 22,
UIContentSizeCategoryAccessibilityExtraLarge: 23,
UIContentSizeCategoryAccessibilityExtraExtraLarge: 24,
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: 25,
]
private static let tableCellDetailDefaultCategorySize: CGFloat = 13
private static let tableCellDetailCategorySizes: [String: CGFloat] = [
UIContentSizeCategoryExtraSmall: 11,
UIContentSizeCategorySmall: 11,
UIContentSizeCategoryMedium: 12,
UIContentSizeCategoryLarge: tableCellDetailDefaultCategorySize,
UIContentSizeCategoryExtraLarge: 14,
UIContentSizeCategoryExtraExtraLarge: 15,
UIContentSizeCategoryExtraExtraExtraLarge: 16,
UIContentSizeCategoryAccessibilityMedium: 17,
UIContentSizeCategoryAccessibilityLarge: 18,
UIContentSizeCategoryAccessibilityExtraLarge: 19,
UIContentSizeCategoryAccessibilityExtraExtraLarge: 20,
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: 21,
]
private static var preferredContentSizeCategory: String {
return UIApplication.sharedApplication().preferredContentSizeCategory
}
private static let headingDefaultCategorySize: CGFloat = 48
static let headingFont: UIFont = {
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(headingDefaultCategorySize, weight: UIFontWeightThin)
} else {
return UIFont(name: "HelveticaNeue-Thin", size: headingDefaultCategorySize) ?? UIFont.systemFontOfSize(headingDefaultCategorySize)
}
}()
private static let subheadingDefaultCategorySize: CGFloat = 24
static let subheadingFont: UIFont = {
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(subheadingDefaultCategorySize, weight: UIFontWeightRegular)
} else {
return UIFont(name: "HelveticaNeue", size: subheadingDefaultCategorySize) ?? UIFont.systemFontOfSize(subheadingDefaultCategorySize)
}
}()
static var bodyFont: UIFont {
let size = bodyCategorySizes[preferredContentSizeCategory] ?? bodyDefaultCategorySize
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(size, weight: UIFontWeightLight)
} else {
return UIFont(name: "HelveticaNeue-Light", size: size) ?? UIFont.systemFontOfSize(size)
}
}
static var bodyBoldFont: UIFont {
let size = bodyCategorySizes[preferredContentSizeCategory] ?? bodyDefaultCategorySize
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(size, weight: UIFontWeightRegular)
} else {
return UIFont(name: "HelveticaNeue", size: size) ?? UIFont.systemFontOfSize(size)
}
}
static var tableCellTitleFont: UIFont {
let size = tableCellTitleCategorySizes[preferredContentSizeCategory] ?? tableCellTitleDefaultCategorySize
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(size, weight: UIFontWeightLight)
} else {
return UIFont(name: "HelveticaNeue-Light", size: size) ?? UIFont.systemFontOfSize(size)
}
}
static var tableCellDetailFont: UIFont {
let size = tableCellDetailCategorySizes[preferredContentSizeCategory] ?? tableCellDetailDefaultCategorySize
if #available(iOS 8.2, *) {
return UIFont.systemFontOfSize(size, weight: UIFontWeightRegular)
} else {
return UIFont(name: "HelveticaNeue", size: size) ?? UIFont.systemFontOfSize(size)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment