Last active
December 18, 2015 22:39
-
-
Save GantMan/5855737 to your computer and use it in GitHub Desktop.
Code Gists from the Book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
@window.makeKeyAndVisible | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Application 'HelloWorld'" do | |
before do | |
@app = UIApplication.sharedApplication | |
@window = @app.windows[0] | |
end | |
it "has one window" do | |
@app.windows.size.should == 1 | |
end | |
it "has a rootViewController" do | |
@window.rootViewController.should.not == nil | |
end | |
it "uses HelloWorldController as the rootViewController" do | |
@window.rootViewController.class.should.equal HelloWorldController | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
@window.rootViewController = HelloWorldController.new | |
@window.makeKeyAndVisible | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
def viewDidLoad | |
puts "Hello World" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "HelloWorldController" do | |
tests HelloWorldController | |
it "has a UILabel with text correct text" do | |
label = controller.instance_variable_get("@label") | |
# check text | |
label.text.should.equal "Hello World" | |
# make sure it is added on the view | |
controller.view.subviews.should.include? label | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
def viewDidLoad | |
p "Hello World" | |
view.backgroundColor = UIColor.whiteColor | |
@label = UILabel.new | |
@label.text = "Hello World" | |
@label.frame = [[50, 50], [150, 50]] | |
view.addSubview(@label) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
def viewDidLoad | |
p "Hello World" | |
view.backgroundColor = UIColor.whiteColor | |
center_x = view.frame.size.width / 2 | |
center_y = view.frame.size.height / 2 | |
@label = UILabel.new | |
@label.text = "Hello World" | |
@label.sizeToFit | |
@label.center = [center_x, center_y] | |
view.addSubview(@label) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project/template/ios' | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'HelloWorld' | |
app.device_family = [:iphone, :ipad] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A sample Gemfile | |
source "https://rubygems.org" | |
gem "awesome_print_motion" | |
gem "teacup" | |
gem "sugarcube" | |
gem "sweettea" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project/template/ios' | |
require 'bundler' | |
Bundler.require | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'HelloWorld' | |
app.device_family = [:iphone, :ipad] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
def viewDidLoad | |
p "Hello World" | |
# Made better with Sugarcube | |
# @colors = [UIColor.whiteColor, UIColor.redColor] | |
@colors = [:white.uicolor, :red.uicolor, :yellow.uicolor, :blue.uicolor] | |
1.second.every do | |
view.backgroundColor = @colors.sample | |
end | |
# see the magic of Awesome Print! | |
ap @colors | |
center_x = view.frame.size.width / 2 | |
center_y = view.frame.size.height / 2 | |
@label = UILabel.new | |
@label.text = "Hello World" | |
@label.sizeToFit | |
@label.center = [center_x, center_y] | |
view.addSubview(@label) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController < UIViewController | |
stylesheet :main | |
layout :main do | |
@label = subview(UILabel, :hello_label) | |
end | |
def layoutDidLoad | |
p "Hello World" | |
# Made better with Sugarcube | |
# @colors = [UIColor.whiteColor, UIColor.redColor] | |
@colors = [:white.uicolor, :red.uicolor, :yellow.uicolor, :blue.uicolor] | |
1.second.every do | |
view.backgroundColor = @colors.sample | |
end | |
# see the magic of Awesome Print! | |
ap @colors | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teacup::Stylesheet.new :main do | |
style :hello_label, | |
text: "Hello World", | |
width: 89, | |
height: 21, | |
center: ['50%', '50%'], | |
backgroundColor: :clear | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teacup::Stylesheet.new :main do | |
style :hello_label, | |
text: "Hello World", | |
sizeToFit: true, | |
center: ['50%', '50%'], | |
backgroundColor: :clear | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment