---
title: "Background/header for Formotion forms in RubyMotion"
description:
  "See this blog to understand how to set background and header in a form
  developed using Formotion in a RubyMotion application"
canonical_url: "https://www.bigbinary.com/blog/set-formotion-background-and-header"
markdown_url: "https://www.bigbinary.com/blog/set-formotion-background-and-header.md"
---

# Background/header for Formotion forms in RubyMotion

See this blog to understand how to set background and header in a form developed
using Formotion in a RubyMotion application

- Author: Neeraj Singh
- Published: June 8, 2013
- Categories: Ruby

[Formotion](https://github.com/clayallsopp/formotion) for
[Rubymotion](http://www.rubymotion.com/) makes it a breeze to create views with
forms. I am building a rubymotion app and my login form uses formotion. I needed
to set background color for my form and here is how you can set a background
color for a form created using Formotion.

```ruby
class LoginViewController < Formotion::FormController

  def viewDidLoad
    super
    view = UIView.alloc.init
    view.backgroundColor = 0x838E61.uicolor
    self.tableView.backgroundView = view
  end
end
```

After the login view is done loading, I'm creating a new UIView and setting its
background color. Then this UIView object is set as the background view to
formotion's table view.

## Setting header image

If you want to add some branding to the login form, you can add a image to the
form's header by adding the below code to `viewDidLoad`:

```ruby
header_image = UIImage.imageNamed('header_image_name.png')
header_view = UIImageView.alloc.initWithImage(header_image)
self.tableView.tableHeaderView = header_view
```

We are creating a `UIImageView` and initializing it with the image we want to
show in the header. Now, set the tableview's tableHeaderView value to the
UIImageView we created.

## Links

- [Human page](https://www.bigbinary.com/blog/set-formotion-background-and-header)
