Skip to content
Simple to use form builder framework for iOS. Built on top of UICollectionViewController.
Swift Ruby Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DSForm.xcodeproj
DSForm
DSFormTests
images
.travis.yml
DSForm.jpg
DSForm.podspec
LICENSE
README.md

README.md

DSForm Logo Build Status codecov Cocoapods platforms GitHub repo size Gitter GitHub Cocoapods Website

Swift framework for creating dynamic forms.

DSForm

DSForm Screencast

Simple and easy to implement iOS Swift framework for building forms. It is builded on top of UICollectionViewController component.

Supports 4 basic types of form elements:

  1. FormElementTitle (top title label of the form)
  2. FormElementButton (subclass of UIButton control)
  3. FormElementTextField (subclass of UITextField control)
  4. FormElementLabel (subclass of UILabel control)

Requirements

  • Xcode 10.2
  • Swift 5.0

Installation

CocoaPods

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'DSForm'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Example usage

  1. Create new UICollectionVewController and make it subbclass of FormCollectionViewController.
  2. Set the formDelegate to self in viewDidLoad() method so we can use the protocol FormDelegate methods in our class.
import UIKit
import DSForm

class ViewController: FormCollectionViewController, FormDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()        
        
        let element1 = FormElementTitle(text: "Please Sign Up")
        let element2 = FormElementTextField(text: "Username")
        let element3 = FormElementTextField(text: "Password")
        let element4 = FormElementButton(title: "Sign Up")
        fields = [element1, element2, element3, element4]
        
        formDelegate = self
    }
    
    func didSubmitForm(fields: [String : String]) {
        print(fields)
    }
}

Form Elements

DSForm supports 4 basic form elements inside our collection:

FormElementTitle

It defines the title of the form and it is a subclass of the standard UILabel control.

let element1 = FormElementTitle(text: "Please Sign Up")

FormElementTitle

FormElementTitle available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var text: String

FormElementTextField

Supports user input and it is a subclass of the standard UITextField control.

var element2 = FormElementTextField(text: "Username")
element2.topLabel = "Username"

FormElementTextField

FormElementTextField available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var topLabel: String
    public var placeholder: String
    public var validation: DSForm.FormValidation
    public var text: String

FormElementButton

Subclass of the standard UIButton control.

let element4 = FormElementButton(title: "Sign Up")

FormElementButton

FormElementButton available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var title: String

FormElementLabel

Subclass of the standard UILabel control.

let element5 = FormElementLabel(text: "Sample text")

FormElementLabel

FormElementLabel available public properties:

    public var font: UIFont
    public var identifier: String
    public var backgroundColor: UIColor
    public var fontColor: UIColor
    public var text: String

ToDo:

  • Reference the delegate property with @IBOutlet for easy connection from Xcode interface builder
  • Add support for more form elements and variations (image, checkmark, radio button etc...)
  • Add validation to UITextField (phone number, email address, numbers, regex, password etc...)
  • Add more styles to form elements
  • Add more Unit Tests
  • Add detailed documentation for every new feature

Done:

  • Add blank space (element) between form elements
  • Added element size property
  • Added CollectionView UIEdgeInsets property
  • Added placeholder text to FormElementTextField
  • Added new .Line style to FormElementTextField

Screenshot Simulator

Screenshot Xcode

You can’t perform that action at this time.