Skip to content

Instantly share code, notes, and snippets.

View MadeByDouglas's full-sized avatar

Douglas Hewitt MadeByDouglas

View GitHub Profile
@MadeByDouglas
MadeByDouglas / extension.swift
Created June 27, 2016 04:40
CollectionView Cells fit across screen the easy way
// Use this one and it pulls flowLayout info, even from storyboard
extension UICollectionViewFlowLayout {
func cellsFitAcrossScreen(numberOfCells: Int, labelHeight: CGFloat, cellShapeRatio: CGFloat) -> CGSize {
//using information from flowLayout get proper spacing for cells across entire screen
let insideMargin = self.minimumInteritemSpacing
let outsideMargins = self.sectionInset.left + self.sectionInset.right
let numberOfDivisions: Int = numberOfCells - 1
let subtractionForMargins: CGFloat = insideMargin * CGFloat(numberOfDivisions) + outsideMargins
@MadeByDouglas
MadeByDouglas / MasterViewController.swift
Created June 27, 2016 04:34
Simple Core Data Photo Implementation the Apple way
//
// MasterViewController.swift
// coreDataTest
//
// Created by Douglas Hewitt on 6/26/16.
// Copyright © 2016 madebydouglas. All rights reserved.
//
import UIKit
import CoreData