Created
October 21, 2010 10:48
-
-
Save danielctull/638282 to your computer and use it in GitHub Desktop.
A category to easily resize the frame of a view.
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
@interface UIView (DCTResizing) | |
- (void)setWidth:(CGFloat)newWidth; | |
- (void)setHeight:(CGFloat)newHeight; | |
@end |
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
@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