Skip to content
This repository has been archived by the owner on May 20, 2018. It is now read-only.
/ TownPlan Public archive

An iOS UIView layout helper. (Defunct: Use autolayout instead!)

License

Notifications You must be signed in to change notification settings

peterp/TownPlan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This project is now defunct, use autolayout instead!

--

TownPlan is an iOS UIView layout helper.

Laying out views in code is rather tedious. I hope that TownPlan improves that experience.

Layout Views with Orientation Changes

Adds a bunch of functionality to a view controller which allows you to specify a views position and the orientation change that it should respond to.

Usage

[self layoutView:view forOrientation:UIInterfaceOrientationPortrait 
      toPosition:CGPointMake(0, 0)];

[self layoutView:view forOrientation:UIInterfaceOrientationLandscapeLeft 
      toPosition:CGPointMake(100, 100)];

And then add this your view controller!

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
                                duration:(NSTimeInterval)duration {
  [self layoutForOrientation:orientation];
}

Now view will change position when your device changes orientation.

Alignment

[view align:TPAlignRight | TP AlignBottom fixed:YES];

Takes a combination of alignment bitmasks to align a view to its superview, settings fixed to YES will set the correct autoresizingMask to keep its position fixed during orientation changes.

Valid arguments are:

- TPAlignTop
- TPAlignRight
- TPAlignBottom
- TPAlignLeft
- TPAlignMiddle (Y axis)
- TPAlignCenter (X axis)

Usage

UIView *pewView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
pewView.backgroundColor = [UIColor brownColor];

// The view must be part of a superview to use `align`
[self.view addSubview:pewView];
[pewView align:TPAlignBottom | TPAlignCenter fixed:YES];

More to come.

About

An iOS UIView layout helper. (Defunct: Use autolayout instead!)

Resources

License

Stars

Watchers

Forks

Packages

No packages published