Skip to content

Instantly share code, notes, and snippets.

@wimbledon
Created May 10, 2014 05:27
Show Gist options
  • Save wimbledon/8878e53bde892f9c6d3d to your computer and use it in GitHub Desktop.
Save wimbledon/8878e53bde892f9c6d3d to your computer and use it in GitHub Desktop.
IMItemTagsCell.m
@interface IMItemTagsCell()
@property (nonatomic, strong) AMTagListView *tagsView;
@end
@implementation IMItemTagsCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor whiteColor];
// Hack: because the height is a variable, but it will adjusted below via delegate
self.tagsView = [[AMTagListView alloc]initWithFrame:CGRectMake(0, 0, self.bounds.size.width, kIMItemDetailTagsCellHeight)];
self.tagsView.scrollEnabled = NO;
self.tagsView.marginX = kIMItemDetailSectionSpacing;
self.tagsView.marginY = kIMItemDetailSectionSpacing;
[self.contentView addSubview:self.tagsView];
}
return self;
}
- (void)setItem:(IMItem *)item
{
_item = item;
[self.tagsView addTag:self.item.brand.name];
for (IMTag *tag in item.tag) {
[self.tagsView addTag:tag.name];
}
[self.tagsView addTag:self.item.condition.name];
[self.tagsView addTag:self.item.size.name];
}
-(CGFloat)cellHeight
{
return self.tagsView.contentSize.height;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment