Skip to content

Instantly share code, notes, and snippets.

View RichFell's full-sized avatar

Rich RichFell

  • SpectrumTV
  • Denver, CO
View GitHub Profile
@RichFell
RichFell / Location.h
Created February 17, 2015 17:32
PFObject subclassing in Obj-C
// Location.h
// TSApp
//
// Created by Rich Fellure on 8/12/14.
// Copyright (c) 2014 TravelSages. All rights reserved.
//
#import <Parse/Parse.h>
#import "Region.h"
@RichFell
RichFell / PDFRender.swift
Created February 18, 2015 15:15
Taking existing pdf and annotating on it with user input.
// PDFRenderer.swift
// MobileMakersAcademy
//
// Created by Rich Fellure on 2/2/15.
// Copyright (c) 2015 Mobile Makers. All rights reserved.
//
import Foundation
class PDFRenderer {
@RichFell
RichFell / gist:fd389b1641c0b3a5fca9
Last active April 12, 2016 14:02
Keyboard Change Frame Notification
NSNotificationCenter.defaultCenter().addObserverForName(UIKeyboardWillChangeFrameNotification, object: nil, queue: nil) { (notification) -> Void in
guard let info: [NSObject: AnyObject] = notification.userInfo,
let keyboardFrameValue = info[UIKeyboardFrameEndUserInfoKey] as? NSValue,
let duration = info[UIKeyboardAnimationDurationUserInfoKey] as? Int else {
return
}
let diff = CGRectGetHeight(keyboardFrameValue.CGRectValue())
UIView.animateWithDuration(Double(duration), animations: { () -> Void in
self.view.frame = CGRect(x: self.view.frame.minX, y: keyboardFrameValue.CGSizeValue().height, width: self.view.frame.width, height: self.view.frame.height)
@RichFell
RichFell / gist:c5f7bb56891b94542b02
Created April 7, 2015 03:00
Objective C UIKeyboardWillChangeFrameNotification
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillChangeFrameNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
NSDictionary *dict = [note userInfo];
NSValue *keyboardFrame = dict[UIKeyboardFrameEndUserInfoKey];
CGRect frame = [keyboardFrame CGRectValue];
NSNumber *duration = dict[UIKeyboardAnimationDurationUserInfoKey];
double durationDouble = [duration doubleValue];
[UIView animateWithDuration:durationDouble animations:^{
self.view.frame = CGRectMake(0, frame.origin.y - self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
}];
}];
-(void)startPulsatingAnimation {
if (!self.shouldPulsate) {return;}
[self removePulsingAnimation];
CABasicAnimation *theAnimation=[CABasicAnimation animationWithKeyPath:OpacityAnimationKey];
theAnimation.duration = 1.0;
theAnimation.repeatCount = HUGE_VALF;
theAnimation.autoreverses = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1.0];
theAnimation.toValue = [NSNumber numberWithFloat:0.0];
[self.layer addAnimation:theAnimation forKey:PulsingAnimation];
@RichFell
RichFell / gist:ab010740ed5ef96fe5c5
Created November 23, 2015 19:38
Programmatic vertical, aspect ratio, and horizontally centered constraints
imageView.frame = self.frame
imageView.image = defaultImage
imageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(imageView)
let views: [String: AnyObject] = ["imageView": imageView]
let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[imageView]|",
options: .AlignAllCenterX,
metrics: nil,
views: views)
addConstraints(verticalConstraints)