谁能告诉我如何添加两个标签,但我仍然在UITableView的Cell.i增加了一个图已经创建了一个视图的UIView一些name.and我已经创建了UIView类两个标签和还设置标签框架,设置文本等。我的问题是在桌面单元中获取该视图,但不是那些标签。添加标签作为子视图的UIView
countLabel.text = @"4";
countLabel.frame=CGRectMake(275, 10, 20, 15);
countLabel.font=[UIFont boldSystemFontOfSize:15.0];
countLabel.textColor=[UIColor colorWithWhite:0.0 alpha:0.5];
countLabel.backgroundColor=[UIColor clearColor];
hrsLabel.text = @"Hours";
hrsLabel.frame=CGRectMake(260, 30, 45, 15);
hrsLabel.font=[UIFont boldSystemFontOfSize:15.0];
hrsLabel.textColor=[UIColor colorWithWhite:0.0 alpha:0.5];
hrsLabel.backgroundColor=[UIColor clearColor];
这仅仅是我设置框,文本像标签在UIView.and
GreenView *greenView = [[GreenView alloc] initWithFrame:CGRectMake(250, 8, 60, 50)];
greenView.backgroundColor = [UIColor colorWithRed:0.000 green:0.690 blue:0.313 alpha:0.5];
[cell.contentView addSubview:greenView];
我在这里补充说UIView的一个实现代码如下cell.and我不知道如何将这些标签添加到我的UIView。请帮帮我。
对不起,如果用英文任何错误。 任何人都请帮助我。 提前感谢。
你能分享你在哪里添加标签UIView的代码? –
添加这些行, [self.contentView addSubview:countLabel]; [self.contentView addSubview:hrsLabel]; –
这段代码是在单独的单元类中吗?如果是这样,你需要分配标签。 –