Skip to content

Instantly share code, notes, and snippets.

@C4Code
C4Code / GrabSaveImageUIButton
Last active Aug 29, 2015
How to grab and save an image from a default UIButton
View GrabSaveImageUIButton
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)
View FirstWorkSpace.m
//
// 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 Apr 14, 2015
Isometric Logo Experiment
View C4IsometricLogo.Swift
//
// 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 Apr 14, 2015
Button - C4Swift style
View MenuButton.swift
//
// 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 Dec 9, 2014
Rough Isometric Line code, Swift C4
View gist:5ba9f368418bd91d3284
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 Nov 4, 2013
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.
View C4WorkSpace.m
//
// C4WorkSpace.m
// C4Code
//
// Created by Travis Kirton on 11/4/2013.
//
#import "MyWorkSpace.h"
@interface C4WorkSpace ()
@C4Code
C4Code / C4Defines.h
Last active Dec 27, 2015
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.
View C4Defines.h
//
// 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 Nov 4, 2013
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.
View C4WorkSpace.m
//
// 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 Nov 4, 2013
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.
View C4WorkSpace.m
//
// 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 Jun 13, 2013
Image Scale add Points
View C4WorkSpace.m
//
// C4WorkSpace.m
// david
//
// Created by moi on 13-06-12.
// Copyright (c) 2013 moi. All rights reserved.
//
#import "C4WorkSpace.h"