Skip to content

Instantly share code, notes, and snippets.

View bdalziel's full-sized avatar

Ben Dalziel bdalziel

View GitHub Profile
+ (CGFloat)getSpacing:(ASPSpacingSize)size traitCollection:(UITraitCollection *)contextTraitCollection {
bool isCompact = !(contextTraitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular);
switch (size) {
case ASPSpacingSizeTiny :
return (isCompact) ? 8.0f : 16.0f;
case ASPSpacingSizeSmall :
return (isCompact) ? 16.0f : 24.0f;
case ASPSpacingSizeLarge :
return (isCompact) ? 24.0f : 48.0f;
}
+ (CGFloat)getUIFontSize:(ASPUITextStyle)style traitCollection:(UITraitCollection *)contextTraitCollection {
bool isCompact = !(contextTraitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular);
CGFloat pointSize = (isCompact) ? 14.0f : 18.0f;
switch (style) {
case ASPUIElementStyleTitle1 :
pointSize = (isCompact) ? 36.0f : 36.0f;
break;
+ (CGFloat)topUIBaselineAdjustment:(ASPUITextElement)element traitCollection:(UITraitCollection *)contextTraitCollection {
ASPUITextStyle elementTextStyle = [self mapUIElementToStyle:element];
UIFont *font = [ASPFontUtil getUIFont:elementTextStyle traitCollection:contextTraitCollection];
return floor(font.ascender - font.capHeight);
}
+ (CGFloat)bottomUIBaselineAdjustment:(ASPUITextElement)element traitCollection:(UITraitCollection *)contextTraitCollection {
ASPUITextStyle elementTextStyle = [self mapUIElementToStyle:element];
UIFont *font = [ASPFontUtil getUIFont:elementTextStyle traitCollection:contextTraitCollection];
return -(floor(font.lineHeight - font.ascender));
//
// FontUtil.swift
// FantasyMovieLeague
//
// Created by Ben Dalziel on 2/17/16.
// Copyright © 2016 Kinetoplay. All rights reserved.
//
import UIKit
//
// ColorUtil.swift
// FantasyMovieLeague
//
// Created by Ben Dalziel on 2/17/16.
// Copyright © 2016 Kinetoplay. All rights reserved.
//
import SwiftHEXColors
class func uiColor(appUIColor: AppUIColors) -> UIColor {
switch appUIColor {
case .NavBarBackground,
.ViewControllerBackground: // References to color abbreviated
return color(AppColors.Beige)
case .ButtonTitleSelected,
.ButtonTitleHighlighted: // References to color abbreviated
return colorWithAlpha(AppColors.Beige, alpha: 0.7)
case .NavBarShadow,
.TableSeparator: // References to color abbreviated
public indirect enum AppUIColors: Int {
case NavBarBackground,
NavBarTint,
NavBarShadow,
NavBarTitle,
PickerNavBarBackground,
PickerNavBarTint,
PickerNavBarTitle,
PickerNavBarTitleAlt,
enum AppColors: String {
case Beige = "#f5efe0",
Gold = "#cda582",
FMLRed = "#fa463c",
BlackVelvet = "#1e0a14",
DarkVelvet = "#321e28",
Velvet = "#4a283e", //503146",
// Alternate colors - use sparingly
FMLRedAlt = "#e14137",
@bdalziel
bdalziel / AppearanceManager.swift
Last active August 18, 2016 19:35
Relies on SwiftHEXColors for some nice UIColor extensions https://github.com/thii/SwiftHEXColors
//
// AppearanceManager.swift
//
// Created by Ben Dalziel on 2/17/16.
//
import UIKit
class AppearanceManager {
@bdalziel
bdalziel / gist:1571bb1d44419d5219f6
Created July 13, 2015 06:17
Some helpful links for App Transport Security in iOS 9
http://www.neglectedpotential.com/2015/06/working-with-apples-application-transport-security/
http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
http://stackoverflow.com/questions/30739473/nsurlsession-nsurlconnection-http-load-failed-on-ios-9
https://github.com/AFNetworking/AFNetworking/issues/2779