Skip to content

Instantly share code, notes, and snippets.

View Calendar Guts Gist
import Cocoa
class ViewController: NSViewController,NSCollectionViewDelegate,NSCollectionViewDataSource,NSCollectionViewDelegateFlowLayout {
private let concurrentQueue = DispatchQueue(label: "calendarQueue", attributes: .concurrent)
//next 2 variables or speed and smoothness in loading
private var currentSection : Int!
private var currentOffset = 0
private let calendar = Calendar.current
View CASpringAnimation Gist
let vw = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
vw.backgroundColor =
self.view.addSubview(vw) =
// Your code with delay
let spring = CASpringAnimation(keyPath: "position.y")
spring.toValue = - 200
spring.damping = 10.0
View Self Returning UIButton
//See below class for example usage
class GIBbutton : UIButton{
var action : ((UIButton!)->Void)!
convenience init(frame:CGRect,controlEvents:[UIControlEvents],targetAction:((UIButton!)->Void)!){
self.frame = frame
action = targetAction
for event in controlEvents{
self.addTarget(self, action: #selector(GIBbutton.performOurAction), forControlEvents: event)
View TextView Tapping
// when setting up your attributed String add an ATTRIBUTE to look for
// in this example button
// when i set up the string for the button I might use this
[NSForegroundColorAttributeName : UIColor.lightGrayColor(),NSFontAttributeName: font,"button":"button"]
func handleTapOnTextView(sender:UITextView){
let storedAttributedString = self.textView.attributedText
let textView = sender.view as! UITextView
agibson73 / UITextView Lines
Last active Aug 29, 2015
UITextViewWithLines **Use with PSPDFTextView
View UITextView Lines
// I have used this with PSPDFTextView
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
//Get the current drawing context
CGContextRef context = UIGraphicsGetCurrentContext();
//Set the line color and width
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.2f].CGColor);
CGContextSetLineWidth(context, 1.0f);
agibson73 / TransitionZoomForward.swift
Created Mar 17, 2015
Custom Transition that zooms in then out
View TransitionZoomForward.swift
// TransitionZoomForward.swift
// Created by Alex Gibson on 3/14/15.
// Free to Use by Anyone
// Have Fun!
import UIKit