-
-
Save dabinghao123/719de94df4f1247b70a9 to your computer and use it in GitHub Desktop.
This file contains 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
@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