Skip to content

Instantly share code, notes, and snippets.

View michaelarmstrong's full-sized avatar

Michael Armstrong michaelarmstrong

View GitHub Profile
@michaelarmstrong
michaelarmstrong / UIViewControllerModalExtension.swift
Created November 24, 2015 16:38
Weird way to find if a view controller is modally presented.
func isModal() -> Bool {
if let presentingViewController = self.presentingViewController {
return true
}
if let presentingViewController = self.presentingViewController?.presentedViewController {
let exists = (presentingViewController === self)
if exists { return true }
}
if let presentedNavViewController = self.navigationController?.presentingViewController?.presentedViewController {
let exists = (presentedNavViewController === self)
@michaelarmstrong
michaelarmstrong / gist:7a11521bffa855725f7e
Created October 29, 2014 17:47
Super duper .gitignore for iOS Developers
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
@michaelarmstrong
michaelarmstrong / UIColor+Additions.m
Created July 1, 2013 08:09
UIColor colorWithHex specify a hex code for use in Cocoa / Cocoa-Touch projects.
+ (UIColor *)colorWithHex:(NSString *)hexCode
{
if (!hexCode) {
return nil;
}
NSString *hex = [hexCode copy];
if ([hex hasPrefix:@"#"]) {
hex = [hex substringFromIndex:1];