Created
May 12, 2012 15:05
-
-
Save toshikazuhorii/2667078 to your computer and use it in GitHub Desktop.
RubyMotionのレイアウト制御ライブラリMotion-layoutsのサンプルを使って遊んでみた。
This file contains hidden or 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.applicationFrame) | |
@window.rootViewController = ExamMotionLayoutViewController.alloc.init | |
@window.rootViewController.wantsFullScreenLayout = true | |
@window.makeKeyAndVisible | |
return true | |
end | |
end | |
class ExamMotionLayoutView < UIView | |
end | |
class ExamMotionLayoutViewLayout | |
include Layouts::Base | |
def self.template | |
UIToolbar { | |
anchor 'top' | |
height 50 | |
resize :top, :right, :left, :width | |
items [ | |
['Cancel', 'touchesCancel'], | |
[:flexible_space], | |
['Show', 'touchesShow'] | |
] | |
} | |
UITextField { | |
id 'nameTextField' | |
delegate @controller | |
top 90 | |
width 85.percent | |
align 'center' | |
text_color '222222' | |
background_color 'FFFFFF' | |
border_style 'rounded' | |
resize :top, :right, :left, :width | |
placeholder 'Input your name' | |
} | |
end | |
end | |
class ExamMotionLayoutViewController < UIViewController | |
def loadView | |
self.view = ExamMotionLayoutView.alloc.init | |
self.view.backgroundColor = UIColor.whiteColor | |
end | |
def viewWillAppear(animated) | |
super | |
view.fromLayout(ExamMotionLayoutViewLayout, self) | |
end | |
def touchesCancel | |
alert = UIAlertView.new | |
alert.message = "Cancelled" | |
alert.addButtonWithTitle("閉じる") | |
alert.show | |
end | |
def touchesShow | |
alert = UIAlertView.new | |
alert.message = @nameTextField.text | |
alert.addButtonWithTitle("閉じる") | |
alert.show | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment