Posts Using NUI with RubyMotion
Post
Cancel

Using NUI with RubyMotion

NUI is an open-source library that allows you to style your iOS applications using CSS-like files and syntax. In my opinion, NUI carries few benefits over its commercial, KickStart backed, competitor Pixate. First; NUI allows you to style your application on the fly while it’s running in the simulator. And Second; NUI styled-elements are not masked/wrapped in their special classes (like those PX* classes with pixate), rather, they remain as their original iOS declarations. The second point makes debugging the simulated application and tracking ons-creen objects (using cmd-hover) much easier.

Installation:
In your RubyMotion application’s Rakefile:

Motion::Project::App.setup do |app|
  #...

  app.pods do
    # ...

    pod 'NUI'
  end
end

Then run `

`` `

Usage:
Create a theme.nss file (which will include your application’s stylesheet). Then in your ``

class AppDelegate

  @@nui_settings = NUISettings.init
  @@nui_settings.setAutoUpdatePath("/absolute/path/to/project/and/theme.nss")

  def application(application, didFinishLaunchingWithOptions:launchOptions)

    @nui = NUIAppearance.init
    # ...

  end

end

Run `

` and check your application in the simulator. Now, any changes to the <ts_code></ts_code> file will be reflected right away to the running application in the simulator. Happy styling

Contents

Search Results