Git Product home page Git Product logo

bpforms's Introduction

BPForms

Dynamic forms for iPhone/iPad - iOS 6, 7 and later (inspired from BZGFormViewController).

Now integrated with the well known JVFloatLabeledTextField.

Forms design

How to get started

install via CocoaPods

platform :ios, '6.0'
pod 'BPForms'

Requirements

  • Xcode4 and above
  • iOS 6.0 or above

Architecture

Form

  • BPFormViewController

Cells

  • BPFormCell implements BPFormCellProtocol
    • BPFormInputCell - "abstract class" and base class for all input cells
      • BPFormInputTextFieldCell uses BPFormTextField
        • BPFormFloatInputTextFieldCell uses BPFormFloatLabelTextField
      • BPFormInputTextViewCell uses BPFormTextView
        • BPFormFloatInputTextViewCell uses BPFormFloatLabelTextView
    • BPFormButtonCell
  • BPFormInfoCell implements BPFormCellProtocol

Appearance

  • BPAppearance

Class Diagram

Check the detailed class diagram.

Dependencies

Demo

Go to /Example, run pod install, and run the target from BPFormsExample.xcworkspace

Usage

For any form you create, you should subclass BPFormViewController or just instantiate it.

Create an input cell

You can create simple input cells (BPFormInputTextFieldCell) or input cells where the label floats above the text value (BPFormFloatInputTextFieldCell - see screenshot).

Just set the properties you need and make sure you set the BPFormViewController instance as delegate for the textField. shouldChangeBlock is used to verify the data entered, so please add the verification code (see example).

BPFormFloatInputTextFieldCell *emailCell = [[BPFormFloatInputTextFieldCell alloc] init];
emailCell.textField.placeholder = @"Email";
emailCell.textField.delegate = self;
emailCell.customCellHeight = 50.0f;
emailCell.mandatory = YES;
emailCell.shouldChangeTextBlock =
        BPValidateBlockWithPatternAndMessage(
            @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}",
            @"The email should look like [email protected]");

Create a button cell

BPFormButtonCell *signUpCell = [[BPFormButtonCell alloc] init];
signUpCell.button.backgroundColor = [UIColor blueColor];
[signUpCell.button setTitle:@"Sign Up" forState:UIControlStateNormal];
signUpCell.button.layer.cornerRadius = 4.0;
signUpCell.button.layer.masksToBounds = YES;
signUpCell.buttonActionBlock = ^(void){
    NSLog(@"Button pressed");
};

Add all the cells to the form controller

  • keep in mind formCells contains an array of sections, each sections with its cells
self.formCells = @[@[emailCell, passwordCell, password2Cell, nameCell, phoneCell], @[signUpCell]];

Add section header or footer

[self setHeaderTitle:@"Please enter your credentials" forSection:0];
[self setFooterTitle:@"When you're done, press <<Sign Up>>" forSection:0];

Tweak appearance

  • use the BPAppearance class to customize the way the forms look
// fonts
[BPAppearance sharedInstance].infoCellLabelFont = [UIFont systemFontOfSize:12];

// colors
[BPAppearance sharedInstance].headerFooterLabelTextColor = [UIColor lightGray];

// sizes
[BPAppearance sharedInstance].infoCellHeight = 25;

Author

License

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.