Latest 0.0.1
Homepage https://github.com/onurersel/UIView-Move
License MIT
Platforms ios 6.0, tvos 9.0, requires ARC
Authors

Purpose

It’s too tidious to reassign unchanged frame values everytime you want to move your UIView, even though you only change a single parameter. UIView-Move supplies helper getter/setter methods for these situations.

Installation

Copy UIView-Move.h and UIView-Move.m files to your project. Or use Cocoapods

pod 'UIView-Move'

Usage

Import category to the class you want to use it in, or

#import "UIView+Move.h"
//Creating a black square to test on
UIView *view = [UIView new];
view.backgroundColor = [UIColor blackColor];
view.frame = CGRectMake(0, 0, 100, 100);
[someView addSubview:view];

//Moving our view around
view.x = 200;
view.y = 250;

//Resizing
view.width = 150;
view.height = 150;

You can position your view relative its parent’s frame

//Following lines will position our rectangle at the center of it's super
view.left = view.superview.width/2.0 - view.width/2.0;
view.top = view.superview.height/2.0 - view.height/2.0;

//This will snap the box to bottom right of superviews frame
view.right = 0;
view.bottom = 0;

//Animates the box to the top left
[UIView animateWithDuration:1 animations:^{
  view.top = 0;
  view.x = 0;
}];

Or you can position the view’s center relative to center of it’s parent frame

//Places view to middle of its parent
view.midX = 0;
view.midY = 0;

Latest podspec

{
    "name": "UIView-Move",
    "version": "0.0.1",
    "authors": {
        "Onur Ersel": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ethestel",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/onurersel/UIView-Move",
    "source": {
        "git": "https://github.com/onurersel/UIView-Move.git",
        "tag": "0.0.1"
    },
    "summary": "UIView category which changes frame values with single parameter rather than assigning CGRects",
    "platforms": {
        "ios": "6.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "UIView+Move.{h,m}"
}

Pin It on Pinterest

Share This