Skip to content

Instantly share code, notes, and snippets.

@agibson73
agibson73 / TransitionZoomForward.swift
Created March 17, 2015 02:23
Custom Transition that zooms in then out
//
// TransitionZoomForward.swift
// Created by Alex Gibson on 3/14/15.
// Free to Use by Anyone
// Have Fun!
//
import UIKit
@agibson73
agibson73 / UITextView Lines
Last active August 29, 2015 14:18
UITextViewWithLines **Use with PSPDFTextView
// 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);
// 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
//See below class for example usage
class GIBbutton : UIButton{
var action : ((UIButton!)->Void)!
convenience init(frame:CGRect,controlEvents:[UIControlEvents],targetAction:((UIButton!)->Void)!){
self.init()
self.frame = frame
action = targetAction
for event in controlEvents{
self.addTarget(self, action: #selector(GIBbutton.performOurAction), forControlEvents: event)
let vw = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
vw.backgroundColor = UIColor.red
self.view.addSubview(vw)
vw.center = self.view.center
// Your code with delay
let spring = CASpringAnimation(keyPath: "position.y")
spring.toValue = vw.center.y - 200
spring.damping = 10.0
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
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: CGRect.zero)
navLabel.backgroundColor = UIColor.clear
navLabel.font = UIFont.systemFont(ofSize: 18)
navLabel.textAlignment = NSTextAlignment.center
#import "SettingsViewController.h"
#import "HomeViewController.h"
#import "AppDelegate.h"
#import "Location+CoreDataClass.h"
#import "LocationManager.h"
#import "DarkSkyAPI.h"
@interface SettingsViewController ()<UISearchBarDelegate>
@agibson73
agibson73 / PulseTouchCollectionViewCell
Created March 12, 2017 00:30
Just a UICollectionview cell animation on touch although it could be performed on any uiview.
import UIKit
@IBDesignable class PulseTouchCollectionViewCell: UICollectionViewCell {
@IBInspectable var scaleFactor : CGFloat = 1.3
@IBInspectable var animationColor : UIColor = UIColor.green
@IBInspectable var startingOpacity : Float = 0.2
@IBInspectable var animationDuration : Double = 0.8
CATransaction.begin()
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
CATransaction.setCompletionBlock({
self.airplane.layer.position = CGPoint(x: self.view.bounds.width - 100, y: self.view.bounds.height - 100)