Skip to content

Instantly share code, notes, and snippets.

@C4Code
C4Code / GrabSaveImageUIButton
Last active August 29, 2015 14:21
How to grab and save an image from a default UIButton
override func viewDidLoad() {
let fileName = "infoLight.png"
let b = UIButton.buttonWithType(UIButtonType.InfoLight) as! UIButton
let img = b.imageForState(.Normal)
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let dir = (paths[0] as! String)+"/"+fileName
UIImagePNGRepresentation(img).writeToFile(dir, atomically: true)
@C4Code
C4Code / FirstWorkSpace.m
Created April 28, 2015 21:19
New Gestures
//
// FirstWorkSpace.m
// tabbed
//
// Created by moi on 12-10-15.
// Copyright (c) 2012 moi. All rights reserved.
//
#import "FirstWorkSpace.h"
@C4Code
C4Code / C4IsometricLogo.Swift
Created April 14, 2015 17:41
Isometric Logo Experiment
//
// C4Logo.swift
// C4Swift
//
// Created by travis on 2014-11-24.
// Copyright (c) 2014 C4. All rights reserved.
//
import Foundation
import C4Core
@C4Code
C4Code / MenuButton.swift
Created April 14, 2015 17:23
Button - C4Swift style
//
// ViewController.swift
// C4Swift
//
// Created by travis on 2014-10-28.
// Copyright (c) 2014 C4. All rights reserved.
//
import UIKit
import C4UI
@C4Code
C4Code / gist:5ba9f368418bd91d3284
Created December 9, 2014 18:14
Rough Isometric Line code, Swift C4
class Rule {
var a: IsometricPoint
var b: IsometricPoint
lazy var targets = [[IsometricPoint]]()
init(_ a: IsometricPoint, _ b: IsometricPoint) {
self.a = a
self.b = b
}
@C4Code
C4Code / C4WorkSpace.m
Created November 4, 2013 18:55
Working with Dictionaries. This example shows how to pass a dictionary between two objects (in this case 2 workspaces). In the main workspace we build the dictionary. In the second workspace we read from the dictionary and build a shape with its variables.
//
// C4WorkSpace.m
// C4Code
//
// Created by Travis Kirton on 11/4/2013.
//
#import "MyWorkSpace.h"
@interface C4WorkSpace ()
@C4Code
C4Code / C4Defines.h
Last active December 27, 2015 09:49
This example builds on the previous, showing how to create a fake Navigation Bar as its own class. This includes a modified C4Defines.h file that contains the predefined variables that we built in the previous example.
//
// C4Defines.h
// C4iOSDevelopment
//
// Created by Travis Kirton on 11-10-12.
// Copyright (c) 2011 mediart. All rights reserved.
//
#import <Foundation/Foundation.h>
@C4Code
C4Code / C4WorkSpace.m
Created November 4, 2013 17:55
Example of how to build a fake nav bar. This creates and adds a nav bar to the main canvas, it also shows how to create a complex object by adding subviews to the object itself, and not the canvas.
//
// C4WorkSpace.m
// C4Code
//
// Created by Travis Kirton on 11/4/2013.
//
//Defines set in "stone" a value for a variable
//These are best to put in C4Defines.h, but here they suffice for this example
#define UA_NAV_BAR_COLOR [UIColor colorWithRed:0.96875 green:0.96875 blue:0.96875 alpha:1]
@C4Code
C4Code / C4WorkSpace.m
Created November 4, 2013 17:36
Defining Colors. This example shows how to define colors and use them in 2 different ways. First, it shows that you can use the newly defined variable in your app. Second, it shows how to set a the default style of an object (i.e. here it is a label) so that all other objects of the same time take the same default color when they are initialized.
//
// C4WorkSpace.m
// C4Code
//
// Created by Travis Kirton on 11/4/2013.
//
//Defines set in "stone" a value for a variable
//These are best to put in C4Defines.h, but here they suffice for this example
#define UA_NAV_BAR_COLOR [UIColor colorWithRed:0.96875 green:0.96875 blue:0.96875 alpha:1]
@C4Code
C4Code / C4WorkSpace.m
Created June 13, 2013 01:35
Image Scale add Points
//
// C4WorkSpace.m
// david
//
// Created by moi on 13-06-12.
// Copyright (c) 2013 moi. All rights reserved.
//
#import "C4WorkSpace.h"