【发布时间】:2014-09-12 06:00:02
【问题描述】:
我添加了带有标签的自定义UItableViewCell。标签在 iOS 6 中可见,但在 iOS 7 中不可见。
-(void)layoutSubviews{
[super layoutSubviews];
self.textLabel.frame = CGRectMake(90.0f ,-5.0f, 200.0f, 50.0f);
self.imageView.frame = CGRectMake(3.0f , 2.0f, 75.0f, 55.0f);
}
-(void)drawRect:(CGRect)rect{
self.imageView.layer.cornerRadius = 5;
self.imageView.layer.masksToBounds = YES;
self.imageView.layer.borderColor = [UIColor colorWithRed:0.0 green:0.4 blue:0.7 alpha:0.9].CGColor;
self.imageView.layer.borderWidth = 2;
[self.textLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:12]];
self.textLabel.backgroundColor = [UIColor clearColor];
[[UIColor grayColor] set];
[videoDurationTextLabel drawInRect:CGRectMake(90, 30, 190, 10) withFont:[UIFont fontWithName:@"Helvetica" size:12]];
[videoFileSizeLabel drawInRect:CGRectMake(170, 30, 190, 15) withFont:[UIFont fontWithName:@"Helvetica" size:12]];
}
TableViewController 类
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"LazyTableCell";
VideoCustomCell *cell = [self.tblView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[VideoCustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = videoRecord.videoTitle;
cell.videoFileSizeLabel = [NSString stringWithFormat:@"%.4lfMb",totalSpaceInMB];
[cell.imageView setImage:[UIImage imageWithData: imgData]];
cell.videoDurationTextLabel = videoRecord.duration;
}
【问题讨论】:
-
你试过在init方法中设置标签的框架吗?
标签: ios uitableview ios7 uilabel