Skip to content

Instantly share code, notes, and snippets.

@asendra
Forked from irace/gist:8712882
Last active August 29, 2015 14:00
Show Gist options
  • Save asendra/11105879 to your computer and use it in GitHub Desktop.
Save asendra/11105879 to your computer and use it in GitHub Desktop.
[subview updateFrame:^(CGPoint *origin, CGSize *size) {
origin->y = floor((CGRectGetHeight(self.bounds) - SubviewHeight)/2);
}];
@interface UIView (Bryan)
- (void)updateFrame:(void (^)(CGPoint *origin, CGSize *size))block;
@end
@implementation UIView (Bryan)
- (void)updateFrame:(void (^)(CGPoint *origin, CGSize *size))block {
CGRect frame = self.frame;
CGPoint origin = frame.origin;
CGSize size = frame.size;
block(&origin, &size);
frame.origin = origin;
frame.size = size;
self.frame = frame;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment