-
-
Save maicoder/1f62f0b77d8a9c7e38b7a56a1fac1e53 to your computer and use it in GitHub Desktop.
Adjust UIView frame category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIView+frameAdjust.h | |
| // fenbi | |
| // | |
| // Created by Tang Qiao on 12-5-31. | |
| // Copyright (c) 2012年 Fenbi.com . All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface UIView (frameAdjust) | |
| - (CGPoint)origin; | |
| - (void)setOrigin:(CGPoint) point; | |
| - (CGSize)size; | |
| - (void)setSize:(CGSize) size; | |
| - (CGFloat)x; | |
| - (void)setX:(CGFloat)x; | |
| - (CGFloat)y; | |
| - (void)setY:(CGFloat)y; | |
| - (CGFloat)height; | |
| - (void)setHeight:(CGFloat)height; | |
| - (CGFloat)width; | |
| - (void)setWidth:(CGFloat)width; | |
| - (CGFloat)tail; | |
| - (void)setTail:(CGFloat)tail; | |
| - (CGFloat)bottom; | |
| - (void)setBottom:(CGFloat)bottom; | |
| - (CGFloat)right; | |
| - (void)setRight:(CGFloat)right; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIView+frameAdjust.m | |
| // fenbi | |
| // | |
| // Created by Tang Qiao on 12-5-31. | |
| // Copyright (c) 2012年 Fenbi.com . All rights reserved. | |
| // | |
| #import "UIView+frameAdjust.h" | |
| @implementation UIView (frameAdjust) | |
| - (CGPoint)origin { | |
| return self.frame.origin; | |
| } | |
| - (void)setOrigin:(CGPoint) point { | |
| self.frame = CGRectMake(point.x, point.y, self.frame.size.width, self.frame.size.height); | |
| } | |
| - (CGSize)size { | |
| return self.frame.size; | |
| } | |
| - (void)setSize:(CGSize) size { | |
| self.frame = CGRectMake(self.x, self.y, size.width, size.height); | |
| } | |
| - (CGFloat)x { | |
| return self.frame.origin.x; | |
| } | |
| - (void)setX:(CGFloat)x { | |
| self.frame = CGRectMake(x, self.y, self.width, self.height); | |
| } | |
| - (CGFloat)y { | |
| return self.frame.origin.y; | |
| } | |
| - (void)setY:(CGFloat)y { | |
| self.frame = CGRectMake(self.x, y, self.width, self.height); | |
| } | |
| - (CGFloat)height { | |
| return self.frame.size.height; | |
| } | |
| - (void)setHeight:(CGFloat)height { | |
| self.frame = CGRectMake(self.x, self.y, self.width, height); | |
| } | |
| - (CGFloat)width { | |
| return self.frame.size.width; | |
| } | |
| - (void)setWidth:(CGFloat)width { | |
| self.frame = CGRectMake(self.x, self.y, width, self.height); | |
| } | |
| - (CGFloat)tail { | |
| return self.y + self.height; | |
| } | |
| - (void)setTail:(CGFloat)tail { | |
| self.frame = CGRectMake(self.x, tail - self.height, self.width, self.height); | |
| } | |
| - (CGFloat)bottom { | |
| return self.tail; | |
| } | |
| - (void)setBottom:(CGFloat)bottom { | |
| [self setTail:bottom]; | |
| } | |
| - (CGFloat)right { | |
| return self.x + self.width; | |
| } | |
| - (void)setRight:(CGFloat)right { | |
| self.frame = CGRectMake(right - self.width, self.y, self.width, self.height); | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment