Skip to content

Instantly share code, notes, and snippets.

@danielctull
Created October 21, 2010 10:48
Show Gist options
  • Save danielctull/638282 to your computer and use it in GitHub Desktop.
Save danielctull/638282 to your computer and use it in GitHub Desktop.
A category to easily resize the frame of a view.
@interface UIView (DCTResizing)
- (void)setWidth:(CGFloat)newWidth;
- (void)setHeight:(CGFloat)newHeight;
@end
@implementation UIView (DCTResizing)
- (void)setWidth:(CGFloat)newWidth {
CGRect oldFrame = self.frame;
self.frame = CGRectMake(oldFrame.origin.x, oldFrame.origin.y, newWidth, oldFrame.size.height);
}
- (void)setHeight:(CGFloat)newHeight {
CGRect oldFrame = self.frame;
self.frame = CGRectMake(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width, newHeight);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment