O'Reilly logo

RubyMotion by Clay Allsopp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required