Git Product home page Git Product logo

simpleview's Introduction

SimpleView

A DSL for UIKit for RubyMotion.

  • Simpler view declaration syntax
  • UIView helper methods
  • View tagging with string

Installation

The lazy and dirty way is to copy the source files into your own project.

Or refer to the blog post Using 3rd Party Ruby Library in RubyMotion.

Usage

def viewDidLoad
  view.setup do
    label width: 200, height: 20, text: "Choose your lucky word", color: UIColor.darkGrayColor
    image_view top: 50, left: 50, image:UIImage.imageName("sample.jpg")
  end
end

Everything inside setup block will be added to the view automatically.

Hash parameters works only on KVC-compliant properties. To configure view object in more detail, use a block

def viewDidLoad
  view.setup do
    button do |btn|
      btn.setTitle("Submit" forState: UIControlStateNormal)
    end
  end
end

Currently support 4 property helpers (more in the future)

  • top
  • left
  • width
  • height

Supported UIViews

  • UIButton via button
  • UIDatePicker via date_picker
  • UIImageView via image_view
  • UILabel via label
  • UIPageControl via page_control
  • UIPickerView via picker_view
  • UIProgressView via progress_view
  • UIScrollView via scroll_view
  • UISearchBar via search_bar
  • UISegmentedControl via segmented_control
  • UISlider via slider
  • UIStepper via stepper
  • UISwitch via swtich
  • UITabBar via tab_bar
  • UITableView via table_view
  • UITableViewCell via table_view_cell
  • UITextField via text_field
  • UITextView via text_view
  • UIToolbar via toolbar
  • UIWebView via web_view

View tagging with string

No need to declare ivar, no need to use integer tag, just name your view and access it by the name.

def viewDidLoad
  view.setup do
    label name: "price_label" # give a name to the label
  end
end

def someOtherMethod
  view.subview("price_label") # get the label
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.