Skip to content

Instantly share code, notes, and snippets.

View bgayman's full-sized avatar

Brad Gayman bgayman

View GitHub Profile
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
var str = "Hello, playground"
private let reuseIdentifier = "Cell"
class NumberCell: UICollectionViewCell {
let numberLabel = UILabel()
let objects:Array<Dictionary<String, AnyObject>> = [["id": NSNull(), "born": 1964, "name": "Keanu Reeves"], ["id": NSNull(), "born": 1967, "name": "Carrie-Anne Moss"], ["id": NSNull(), "born": 1961, "name": "Laurence Fishburne"], ["id": NSNull(), "born": 1960, "name": "Hugo Weaving"], ["id": NSNull(), "born": 1967, "name": "Andy Wachowski"], ["id": NSNull(), "born": 1965, "name": "Lana Wachowski"], ["id": NSNull(), "born": 1952, "name": "Joel Silver"], ["id": NSNull(), "born": NSNull(), "name": "Ann"], ["id": NSNull(), "born": NSNull(), "name": "Dan"]]
let object = objects[1]
print("Object is: \(objects)")
print("Hello")
print(object["name"]?.classForCoder)
let text = object["name"] as! String
print(object["born"]?.classForCoder)
let text2 = object["born"] as! Int
let label = UILabel(frame: CGRect(x: 0.0, y: 0.0, width: 300.0, height: 100.0))
label.numberOfLines = 0
label.backgroundColor = UIColor.yellowColor()
label.lineBreakMode = .ByWordWrapping
label.text = "Hello 😇\n🤑蠓蝾"
let fontSize:CGFloat = 54.0
label.font = UIFont.systemFontOfSize(fontSize)
let size = label.sizeThatFits(CGSize(width: 100.0, height: CGFloat.max))
label
label.sizeToFit()
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface KerningLabel : UILabel
@property (nonatomic) IBInspectable CGFloat kerning;
@end
import UIKit
import PlaygroundSupport
extension UIView
{
var snapshot: UIImage?
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, false, 0)
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
import UIKit
import PlaygroundSupport
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
{
let tableView = UITableView(frame: CGRect.zero, style: .plain)
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
var text = ["dog 🐶", "cat 🐱", "mouse 🐭", "bird 🐦", "rat 🐀", "chicken 🐔"]
import UIKit
class SpringyCollectionViewFlowLayout: UICollectionViewFlowLayout
{
lazy var dynamicAnimator: UIDynamicAnimator =
{
return UIDynamicAnimator(collectionViewLayout: self)
}()
var visibleIndexPathsSet = Set<IndexPath>()
@bgayman
bgayman / FilterCam.swift
Last active September 25, 2022 00:42
Setup AVCaptureSession with CIFilter
//
// ViewController.swift
// CameraFilter
//
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate {
//
// ObjcViewController.m
// FilterCam
//
// Created by B Gay on 11/3/17.
// Copyright © 2017 B Gay. All rights reserved.
//
#import "ObjcViewController.h"
#import <AVFoundation/AVFoundation.h>