Created
December 21, 2011 04:11
-
-
Save KatagiriSo/1504534 to your computer and use it in GitHub Desktop.
Simple Frame Property
This file contains 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
// Simple Frame Property | |
@interface UIView(FrameUtil) | |
@property (nonatomic,assign) float originX; | |
@property (nonatomic,assign) float originY; | |
@property (nonatomic,assign) float width; | |
@property (nonatomic,assign) float height; | |
@property (nonatomic,assign) CGSize size; | |
@property (nonatomic,assign) CGPoint origin; | |
@end | |
@implementation UIView(FrameUtil) | |
- (void)setSize:(CGSize)size | |
{ | |
CGPoint point = self.frame.origin; | |
[self setFrame:CGRectMake(point.x, point.y, size.width, size.height)]; | |
} | |
- (void)setOrigin:(CGPoint)point | |
{ | |
CGSize size = self.frame.size; | |
[self setFrame:CGRectMake(point.x, point.y, size.width, size.height)]; | |
} | |
- (CGSize)size | |
{ | |
return self.frame.size; | |
} | |
- (CGPoint)origin | |
{ | |
return self.frame.origin; | |
} | |
- (float)width | |
{ | |
return self.size.width; | |
} | |
- (float)height | |
{ | |
return self.size.height; | |
} | |
- (float)originX | |
{ | |
return self.origin.x; | |
} | |
- (float)originY | |
{ | |
return self.origin.y; | |
} | |
- (void)setWidth:(float)width | |
{ | |
[self setSize:CGSizeMake(width,self.height)]; | |
} | |
- (void)setHeight:(float)height | |
{ | |
[self setSize:CGSizeMake(self.width, height)]; | |
} | |
- (void)setOriginX:(float)originX | |
{ | |
[self setOrigin:CGPointMake(originX, self.originY)]; | |
} | |
- (void)setOriginY:(float)originY | |
{ | |
[self setOrigin:CGPointMake(self.originX, originY)]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
view.originX = 30.0;
view.height = 20.0;