如何获取UILabel中指定文字的CGRect
1个回答
2016-08-23 · 百度知道合伙人官方认证企业
兄弟连教育
兄弟连教育成立于2006年,11年来专注IT职业教育,是国内专业的IT技术培训学校。2016年成功挂牌新三板(股票代码:839467)市值过亿。开设专注程序员培训专注php、Java、UI、云计算、Python、HTML5、
向TA提问
关注
展开全部
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"shoppingCell";
ShoppingGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[ShoppingGoodsCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellIdentifier];
}
else
{
while (cell.contentView.subviews.lastObject != nil) {
[cell.contentView.subviews.lastObject removeFromSuperview];
}
}
UILabel *goodsName = [[UILabel alloc]initWithFrame:CGRectMake(80, 2, 205, 45)];
goodsName.font = [UIFont fontWithName:@"Helvetica" size:12];
goodsName.numberOfLines = 2;
goodsName.text = @"sjogjeojgesjgpesgpsejgpespgjspengosehgespgkerpogepgjpeosgjespofgjpes";
UILabel *numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 47, 205, 30)];
numberLabel.font = [UIFont fontWithName:@"Helvetica" size:12];
numberLabel.text = [countArray objectAtIndex:indexPath.row];
numberLabel.tag = indexPath.row;
{
static NSString *cellIdentifier = @"shoppingCell";
ShoppingGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[ShoppingGoodsCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellIdentifier];
}
else
{
while (cell.contentView.subviews.lastObject != nil) {
[cell.contentView.subviews.lastObject removeFromSuperview];
}
}
UILabel *goodsName = [[UILabel alloc]initWithFrame:CGRectMake(80, 2, 205, 45)];
goodsName.font = [UIFont fontWithName:@"Helvetica" size:12];
goodsName.numberOfLines = 2;
goodsName.text = @"sjogjeojgesjgpesgpsejgpespgjspengosehgespgkerpogepgjpeosgjespofgjpes";
UILabel *numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 47, 205, 30)];
numberLabel.font = [UIFont fontWithName:@"Helvetica" size:12];
numberLabel.text = [countArray objectAtIndex:indexPath.row];
numberLabel.tag = indexPath.row;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询