Skip to content

Instantly share code, notes, and snippets.

@KatagiriSo
Created December 21, 2011 04:11
Show Gist options
  • Save KatagiriSo/1504534 to your computer and use it in GitHub Desktop.
Save KatagiriSo/1504534 to your computer and use it in GitHub Desktop.
Simple Frame Property
// 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
@KatagiriSo
Copy link
Author

view.originX = 30.0;
view.height = 20.0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment