Skip to content

Instantly share code, notes, and snippets.

@gabriel
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabriel/682c23a4b7210c1fc06b to your computer and use it in GitHub Desktop.
Save gabriel/682c23a4b7210c1fc06b to your computer and use it in GitHub Desktop.
// MyView.m
#import "MyView.h"
@interface MyView ()
@property UIImageView *imageView;
@property DynamicHeightSubview *dynamicHeightSubview;
@end
@implementation MyView
- (void)sharedInit {
self.layout = [YOLayout layoutWithView:self];
_imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MyImage.png"]];
_dynamicHeightSubview = [[DynamicHeightSubview alloc] init];
}
- (CGSize)layout:(id<YOLayout>)layout size:(CGSize)size {
CGFloat x = 10;
CGFloat y = 10;
x += [layout setOrigin:CGPointMake(x, y) view:_imageView].size.width + 10;
y += [layout setFrame:CGRectMake(x, y, size.width - x - 10, 0) sizeThatFits:YES].size.height;
return CGSizeMake(size.width, y);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment