-
-
Save CoderXL/8967417 to your computer and use it in GitHub Desktop.
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
| /* | |
| Before: | |
| CGRect frame = myView.frame; | |
| frame.origin.x = newX; | |
| myView.frame = frame; | |
| After: | |
| myView.x = newX; | |
| */ | |
| #import <UIKit/UIKit.h> | |
| @interface UIView (Ext) | |
| @property float x; | |
| @property float y; | |
| @property float width; | |
| @property float height; | |
| @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
| #import "UIView+Ext.h" | |
| @implementation UIView (Ext) | |
| -(float) x { | |
| return self.frame.origin.x; | |
| } | |
| -(void) setX:(float) newX { | |
| CGRect frame = self.frame; | |
| frame.origin.x = newX; | |
| self.frame = frame; | |
| } | |
| -(float) y { | |
| return self.frame.origin.y; | |
| } | |
| -(void) setY:(float) newY { | |
| CGRect frame = self.frame; | |
| frame.origin.y = newY; | |
| self.frame = frame; | |
| } | |
| -(float) width { | |
| return self.frame.size.width; | |
| } | |
| -(void) setWidth:(float) newWidth { | |
| CGRect frame = self.frame; | |
| frame.size.width = newWidth; | |
| self.frame = frame; | |
| } | |
| -(float) height { | |
| return self.frame.size.height; | |
| } | |
| -(void) setHeight:(float) newHeight { | |
| CGRect frame = self.frame; | |
| frame.size.height = newHeight; | |
| self.frame = frame; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment