Created
April 22, 2015 15:37
-
-
Save colinta/8889db978032a9417884 to your computer and use it in GitHub Desktop.
example of a UIToolbar
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) | |
rootViewController = ToolbarController.alloc.init | |
rootViewController.title = 'toolbar' | |
rootViewController.view.backgroundColor = UIColor.whiteColor | |
navigationController = UINavigationController.alloc.initWithRootViewController(rootViewController) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
@window.rootViewController = navigationController | |
@window.makeKeyAndVisible | |
true | |
end | |
end | |
class ToolbarController < UIViewController | |
def loadView | |
@layout = ToolbarLayout.new | |
self.view = @layout.view | |
end | |
end | |
class ToolbarLayout < MK::Layout | |
def layout | |
add UIToolbar, :toolbar | |
end | |
def toolbar_style | |
frame from_bottom(height: 100, width: '100%') | |
autoresizing_mask :fill_bottom | |
items [ | |
UIBarButtonItem.alloc.initWithTitle( | |
"Hello", | |
style: UIBarButtonItemStylePlain, | |
target: self, | |
action: 'hello_pressed:' | |
), | |
UIBarButtonItem.alloc.initWithBarButtonSystemItem( | |
UIBarButtonSystemItemFlexibleSpace, | |
target: nil, | |
action: nil | |
), | |
UIBarButtonItem.alloc.initWithBarButtonSystemItem( | |
UIBarButtonSystemItemAction, | |
target: self, | |
action: 'hello_pressed:' | |
) | |
] | |
end | |
def hello_pressed(sender) | |
puts("hello") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment