Skip to content

Instantly share code, notes, and snippets.

@colinta
Created April 22, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinta/8889db978032a9417884 to your computer and use it in GitHub Desktop.
Save colinta/8889db978032a9417884 to your computer and use it in GitHub Desktop.
example of a UIToolbar
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