Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@implementation FBStoryView
{
FBHeaderView *_headerView;
FBMessageView *_messageView;
FBAttachmentView *_attachmentView;
FBLikeBarView *_likeBarView;
}
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
_headerView = [[FBHeaderView alloc] init];
_messageView = [[FBMessageView alloc] init];
_attachmentView = [[FBAttachmentView alloc] init];
_likeBarView = [[FBLikeBarView alloc] init];
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_headerView][_messageView][_attachmentView][_likeBarView]|"
options:NSLayoutFormatAlignAllLeft
metrics:@{}
views:NSDictionaryOfVariableBindings(_headerView, _messageView, _attachmentView, _likeBarView)]];
for (UIView *view in @[_headerView, _messageView, _attachmentView, _likeBarView]) {
[self addSubview:view];
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[view]|"
options:NSLayoutFormatAlignAllTop
metrics:@{}
views:@{@"view": view}]];
}
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment