Making Shapes and Colors

Let’s get to some code. Create a new app called Boxey (remember how? motion create Boxey). Now we need to add a window to our app.

Adding a UIWindow should be one of the first things your app does, so we need to add it in AppDelegate’s application:didFinishLaunchingWithOptions:, like this:

 class​ AppDelegate
 def​ application(application, didFinishLaunchingWithOptions​:launchOptions​)
  @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
  @window.backgroundColor = UIColor.whiteColor
  @window.makeKeyAndVisible

There are a couple of new classes in there, so let’s walk through it. We created our UIWindow using initWithFrame:. We use this method to create all ...

Get RubyMotion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.