Skip to content

Instantly share code, notes, and snippets.

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
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
//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)
// 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
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);
@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