Latest 0.1.0
Homepage https://github.com/AbZorbaGames/uiview-position
License MIT
Platforms ios 7.0, requires ARC
Authors

CI Status
Version
License
Platform

Usage

Quickly compute positions for UIViews.

Do you often write code like this?:

// position view so that its right edge equals the superviews right edge and the bottom right corner of that view to be the same as its superview
view.frame = CGRectMake(CGRectGetMaxY(superview.frame) - CGRectGetWidth(view.frame),
                            CGRectGetMaxY(superview.frame) - CGRectGetHeight(view.frame),
                            CGRectGetWidth(view.frame),
                            CGRectGetHeight(view.frame));

Wouldn’t it be simpler if you wrote JUST this:

view.frameBottomRight = superview.ownBottomRight;
This category provides a convenient way to position your UIViews using any corner or edge of the coordinate system.

Examples

// position redView so that its right edge == self.view right edge and the center.y == self.view.center.y
redView.frameRightCenter = self.view.ownRightCenter;
// position blueView so that its right edge equals redView's left edge and the center.y equals with redView's bottom
blueView.frameRightCenter = _redView.frameBottomLeft;
// position greenView so that its bottom edge equals redView's top edge and the right edge equals with redView's center.x
greenView.frameBottomRight = _redView.frameTopCenter;
// move a view down 5 points
view.frameTop += 5;
//view.frameBottom += 5;

Installation

There are two ways to use uiview-position in your project:

  • using CocoaPods
  • copying all the files into your project

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.

Podfile

pod 'uiview-position'

Quick start

Just add UIView+Position.h and UIView+Position.m to your project. Import UIView+Position.h and start using the extensions.

#import "UIView+Position.h"

Author

AbZorbaGames, [email protected]

License

uiview-position is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "uiview-position",
    "version": "0.1.0",
    "summary": "Convenience methods for positioning easily UIView relative to other views and points",
    "description": "Convenience methods for positioning easily UIView relative to other views and points.",
    "homepage": "https://github.com/AbZorbaGames/uiview-position",
    "license": "MIT",
    "authors": {
        "AbZorbaGames": "[email protected]"
    },
    "source": {
        "git": "https://github.com/AbZorbaGames/uiview-position.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": [
        "Pod/Classes/**/*",
        "*.{h,m}"
    ],
    "resource_bundles": {
        "uiview-position": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This