// // UMImagePickerGroupCell.m // UMCommunity // // Created by luyiyuan on 14/9/9. // Copyright (c) 2014年 Umeng. All rights reserved. // #import "UMImagePickerGroupCell.h" #import "UMImagePickerThumbnailView.h" #import "UMComResouceDefines.h" #import @interface UMImagePickerGroupCell() @property (nonatomic, strong) UMImagePickerThumbnailView *thumbnailView; @property (nonatomic, strong) UILabel *nameLabel; @property (nonatomic, strong) UILabel *countLabel; @end @implementation UMImagePickerGroupCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Cell settings self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; // Create thumbnail view UMImagePickerThumbnailView *thumbnailView = [[UMImagePickerThumbnailView alloc] initWithFrame:CGRectMake(8, 4, 70, 74)]; thumbnailView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; [self.contentView addSubview:thumbnailView]; self.thumbnailView = thumbnailView; // Create name label UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(8 + 70 + 18, 22, 180, 21)]; nameLabel.font = [UIFont systemFontOfSize:17]; nameLabel.textColor = [UIColor blackColor]; nameLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth; [self.contentView addSubview:nameLabel]; self.nameLabel = nameLabel; // Create count label UILabel *countLabel = [[UILabel alloc] initWithFrame:CGRectMake(8 + 70 + 18, 46, 180, 15)]; countLabel.font = [UIFont systemFontOfSize:12]; countLabel.textColor = [UIColor blackColor]; countLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth; [self.contentView addSubview:countLabel]; self.countLabel = countLabel; } return self; } // 自绘分割线 - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); CGContextFillRect(context, rect); CGContextSetStrokeColorWithColor(context,UMComTableViewSeparatorColor.CGColor); CGContextStrokeRect(context, CGRectMake(0, rect.size.height - TableViewCellSpace, rect.size.width, TableViewCellSpace)); } #pragma mark - Accessors - (void)setAssetsGroup:(ALAssetsGroup *)assetsGroup { _assetsGroup = assetsGroup; // Update thumbnail view self.thumbnailView.assetsGroup = self.assetsGroup; // Update label self.nameLabel.text = [self.assetsGroup valueForProperty:ALAssetsGroupPropertyName]; self.countLabel.text = [NSString stringWithFormat:@"%ld", (long)self.assetsGroup.numberOfAssets]; } @end