We write about Ruby on Rails, React.js, React Native, remote work, open source, engineering and design.
Formotion for Rubymotion 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.
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.
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
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.