Skip to content

Instantly share code, notes, and snippets.

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
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);
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
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 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 gist:87a44defc2f8e9088aa2970fecd7e8e9
call in viewDidLoad
setUpNavBar(bottomBorderColor: .white, opacity: 0.4, height: 1)
func setUpNavBar(bottomBorderColor:UIColor,opacity:Float,height:CGFloat){
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
let navLabel = UILabel(frame:
navLabel.backgroundColor = UIColor.clear
navLabel.font = UIFont.systemFont(ofSize: 18)
navLabel.textAlignment =
View Help
#import "SettingsViewController.h"
#import "HomeViewController.h"
#import "AppDelegate.h"
#import "Location+CoreDataClass.h"
#import "LocationManager.h"
#import "DarkSkyAPI.h"
@interface SettingsViewController ()<UISearchBarDelegate>
agibson73 / PulseTouchCollectionViewCell
Created Mar 12, 2017
Just a UICollectionview cell animation on touch although it could be performed on any uiview.
View PulseTouchCollectionViewCell
import UIKit
@IBDesignable class PulseTouchCollectionViewCell: UICollectionViewCell {
@IBInspectable var scaleFactor : CGFloat = 1.3
@IBInspectable var animationColor : UIColor =
@IBInspectable var startingOpacity : Float = 0.2
@IBInspectable var animationDuration : Double = 0.8
View Change image at the end
let animation = CABasicAnimation(keyPath: "position")
animation.toValue = NSValue(cgPoint: CGPoint(x: self.view.bounds.width - 100, y: self.view.bounds.height - 100))
animation.fromValue = NSValue(cgPoint: position)
animation.duration = 5
animation.isRemovedOnCompletion = false
animation.fillMode = kCAFillModeForwards
self.airplane.layer.position = CGPoint(x: self.view.bounds.width - 100, y: self.view.bounds.height - 100)
View gist:adc79b6f06d2fc92a93a9cc75ca5ec68
//In the controllers to not rotate
override var shouldAutorotate : Bool {
return false
override var supportedInterfaceOrientations : UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
//otherwise i did not change anything. and as long as all orientations are supported if you don't set above it will rotate.
// on dismiss i think it reoriented but i might have ask for layout or something cannot remember.