Latest 1.0.2
Homepage https://github.com/ArtSabintsev/UIView-AutoLayoutView
License MIT
Platforms ios 5.0, requires ARC
Authors

UIView+AutoLayoutView

About

A small Objective-C category on UIView that creates a UIView object that is ready to be used for programmatic AutoLayout. This class is useful for those of us who do a lot of our AutoLayout definitions outside of xibs and storyboards.

Changelog (v1.0.2)

  • Explicitly imported UIKit
  • Added Swift documentation to README

Installation Instructions

CocoaPods

pod 'UIView-AutoLayoutView'

Manual

Simply drop the UIView+AutoLayoutView folder into your project, and reference UIView+AutoLayoutView.h in the classes that need access to the information it provides.

The Interface

@interface UIView (AutoLayoutView)

+ (instancetype)newAutoLayoutView;
+ (void)updateLayoutForView:(UIView *)view;

@end

The Implementation

+ (instancetype)newAutoLayoutView
{
    UIView *view = [self new];
    [view setTranslatesAutoresizingMaskIntoConstraints:NO];

    return view;
}

+ (void)updateLayoutForView:(UIView *)view
{
    [view setNeedsLayout];
    [view layoutIfNeeded];
}

@end

Setup

Objective-C


// Create an AutoLayout view
MyView *myView = [MyView autoLayoutNew]; // Creates a new progrmmatic-AutoLayout ready object

// Update the view after the constraints are set
[UIView updateLayoutForView:myView];

Swift


// Create an AutoLayout view
let myView = MyView.autoLayoutNew() // Creates a new progrmmatic-AutoLayout ready object

// Update the view after the constraints are set
UIView.updateLayoutForView(myView);

Created and Maintained by

Arthur Ariel Sabintsev

Latest podspec

{
    "name": "UIView-AutoLayoutView",
    "version": "1.0.2",
    "summary": "A small Objective-C category on `UIView` that creates a UIView object that is ready to be used in programmatic AutoLayout.",
    "homepage": "https://github.com/ArtSabintsev/UIView-AutoLayoutView",
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/ArtSabintsev/UIView-AutoLayoutView.git",
        "tag": "1.0.2"
    },
    "source_files": "UIView+AutoLayoutView/*.{h,m}",
    "requires_arc": true,
    "authors": {
        "Arthur Ariel Sabintsev": "[email protected]"
    },
    "license": "MIT"
}

Pin It on Pinterest

Share This