Skip to content

Instantly share code, notes, and snippets.

@vpdn
Last active August 29, 2015 14:03
Show Gist options
  • Save vpdn/a64dcf075a396123f2e5 to your computer and use it in GitHub Desktop.
Save vpdn/a64dcf075a396123f2e5 to your computer and use it in GitHub Desktop.
UIView frame adjustment helper
/**
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