Latest 1.0.5
Homepage https://github.com/jonathantribouharet/JTScrollViewController
License MIT
Platforms ios 7.0, requires ARC
Dependencies Masonry
Authors

CI Status
Version
License
Platform

JTScrollViewController help you to create pragmatically a UIViewController with a UIScrollView which take all the space available using Auto Layout without using a nib file.
It creates all constraints required for your views.

Installation

With CocoaPods, add this line to your Podfile.

pod 'JTScrollViewController', '~> 1.0'

Usage

Create a controller which inherit from JTScrollViewController.

#import <UIKit/UIKit.h>
#import <JTScrollViewController.h>

@interface MyViewController : JTScrollViewController

@end

Create your views in the viewDidLoad and call configureConstraintsForSubviews for create all constraints.
You can call addVerticalSpacingForStatusBar when you don’t want the scrollView go under the status bar.

Each views are displayed in the orders they were added to contentView.
You have to set the height of each views by setting the height of their frames.
You can also add a space between each views by settings y property of their frames.

#import "MyViewController.h"

@implementation MyViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Add all your views to self.contentView
    // Do your stuff...
    {
        CGFloat spaceFromTop = 30.;
        UITextField *textField = [UITextField alloc] initWithFrame:CGRectMake(0, spaceFromTop, 0, 45)];
        [self.contentView addSubview:textField];
    }

    {
        UITextField *textField = [UITextField alloc] initWithFrame:CGRectMake(0, 5, 0, 45)];
        [self.contentView addSubview:textField];
    }

    {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 0, 50)];
        [self.contentView addSubview:button];
    }

    // Add vertical space (22px) for the status bar
    // Use this when you don't have a navigation bar and you don't want the scroll go under the status bar
    [self addVerticalSpacingForStatusBar:YES];

    // Call configureConstraintsForSubviews for create all constraints
    [self configureConstraintsForSubviews];
}

Requirements

  • iOS 7 or higher
  • Automatic Reference Counting (ARC)

Author

License

JTScrollViewController is released under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "JTScrollViewController",
    "version": "1.0.5",
    "summary": "Create ScrollViewController pragmatically using Auto Layout.",
    "homepage": "https://github.com/jonathantribouharet/JTScrollViewController",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "Jonathan Tribouharet": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/jonathantribouharet/JTScrollViewController.git",
        "tag": "1.0.5"
    },
    "source_files": "JTScrollViewController/*",
    "requires_arc": true,
    "dependencies": {
        "Masonry": [
            "~> 0"
        ]
    }
}

Pin It on Pinterest

Share This