我有一个需要像这样一个实现代码如下细胞:动态的UILabel - UIImage的 - 的UILabel下令设置
基本上我有左侧,将始终保持相同长度的标签。这没有问题。在右边我有一个标签,将在长度发生变化,比如它包含这显然从因人而异某人的名字。该标签需要与单元格对齐,也没有问题。
的问题是,在动态标签的左边,我想有一个静态的UIImage,这将是说从动态标签10个像素,但也跟着移动。
想法?
这是当前的代码,该图像是该标签的一个子视图,但显然不是动态移动。
// Add text label
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 0.0, 80.0, 45.0)];
textLabel.backgroundColor = [UIColor clearColor];
textLabel.text = @"Account";
textLabel.opaque = NO;
textLabel.textColor = [UIColor colorWithRed:143/255 green:143/255 blue:143/255 alpha:.6];
textLabel.font = [UIFont boldSystemFontOfSize:15];
textLabel.shadowColor = [UIColor whiteColor];
textLabel.shadowOffset = CGSizeMake(0.0, 1.0);
//Add the image
UIImage *image = [UIImage imageNamed:@"image.png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 13.5, 18, 18)];
[imageView image];
// Add the Next Value label
UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(170, 0.0, 100, 45.0)];
valueLabel.textAlignment = UITextAlignmentRight;
valueLabel.textColor = [UIColor colorWithRed:143/255 green:143/255 blue:143/255 alpha:.6];
valueLabel.backgroundColor = [UIColor clearColor];
valueLabel.opaque = NO;
valueLabel.font = [UIFont systemFontOfSize:15];
valueLabel.text = [[NSUserDefaults standardUserDefaults] valueForKey:@"name"];
[cell addSubview:textLabel];
[cell addSubview:valueLabel];
[valueLabel imageView];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
显示你迄今为止尝试过的东西。 Stackoverflow不是一个代码写入服务。 – Madbreaks
我完全知道Stackoverflow是什么。上面的代码显然是不工作的,并没有真正影响到的答案,但我张贴反正 – JeffN