@@ -37,7 +37,8 @@ - (void)layoutSubviews {
3737
3838@interface ImageTableViewCell : UITableViewCell
3939
40- @property (nonatomic , strong ) UILabel *customTextLabel;
40+ @property (nonatomic , strong ) UILabel *hostLabel;
41+ @property (nonatomic , strong ) UILabel *titleLabel;
4142@property (nonatomic , strong ) UIImageView *customImageView;
4243
4344@end
@@ -51,17 +52,22 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
5152 _customImageView.clipsToBounds = YES ;
5253 _customImageView.layer .cornerRadius = 10 ;
5354 [self .contentView addSubview: _customImageView];
54- _customTextLabel = [[UILabel alloc ] init ];
55- [self .contentView addSubview: _customTextLabel];
55+ _hostLabel = [[UILabel alloc ] init ];
56+ _hostLabel.font = [UIFont systemFontOfSize: 12 ];
57+ [self .contentView addSubview: _hostLabel];
58+ _titleLabel = [[UILabel alloc ] init ];
59+ _titleLabel.font = [UIFont systemFontOfSize: 12 weight: UIFontWeightBold];
60+ [self .contentView addSubview: _titleLabel];
5661 }
5762 return self;
5863}
5964
6065- (void )layoutSubviews {
6166 [super layoutSubviews ];
62- self.customImageView .frame = CGRectInset (self.bounds , 20 , 20 );
63- [self .customTextLabel sizeToFit ];
64- self.customTextLabel .frame = CGRectMake (20 , self.bounds .size .height - 20 , self.bounds .size .width - 40 , self.customTextLabel .frame .size .height );
67+ self.customImageView .frame = CGRectInset (self.bounds , 20 , 40 );
68+ self.hostLabel .frame = CGRectMake (30 , self.bounds .size .height - 20 , self.bounds .size .width - 2 * 30 , 20 );
69+ self.titleLabel .frame = CGRectMake (30 , self.bounds .size .height - 40 , self.bounds .size .width - 2 * 30 , 20 );
70+
6571}
6672
6773@end
@@ -147,8 +153,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
147153 if (![cell isKindOfClass: ImageTableViewCell.class]) {
148154 cell = [[ImageTableViewCell alloc ] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier];
149155 }
150- ((ImageTableViewCell *)cell).customTextLabel .text = url.host ;
151- [((ImageTableViewCell *)cell).customImageView sd_setImageWithURL: url];
156+ ((ImageTableViewCell *)cell).hostLabel .text = url.host ;
157+ [((ImageTableViewCell *)cell).customImageView sd_setImageWithURL: url completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
158+ if (image) {
159+ id extendedObject = image.sd_extendedObject ;
160+ if ([extendedObject isKindOfClass: LPLinkMetadata.class]) {
161+ ((ImageTableViewCell *)cell).titleLabel .text = ((LPLinkMetadata *)extendedObject).title ;
162+ }
163+ }
164+ }];
152165 }
153166
154167 return cell;
0 commit comments