Last active
August 29, 2015 14:03
-
-
Save vpdn/a64dcf075a396123f2e5 to your computer and use it in GitHub Desktop.
UIView frame adjustment helper
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
/** | |
Simple category to adjust a view's frame in a contained scope. | |
No more need for littered local variable names. | |
Usage | |
----- | |
[view adjustFrame:^(CGRect *frame) { | |
frame->origin.x = 42.0; | |
}]; | |
**/ | |
#import "UIView+FrameHelper.h" | |
@implementation UIView(FrameHelper) | |
- (void)adjustFrame:(void (^)(CGRect *frame))block { | |
CGRect frame = self.frame; | |
if (block) { | |
block(&frame); | |
} | |
self.frame = CGRectIntegral(frame); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment