我有2个图像,我想并排加入,并在配件视图中显示。
CGSize itemSize = CGSizeMake(40, 40);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(20.0, 20.0, 20, 20);
[[UIImage imageNamed:@"homesmall.png"] drawInRect:imageRect];
CGRect imageRect1 = CGRectMake(0.0, 0.0, 20, 20);
[[UIImage imageNamed:@"update.png"] drawInRect:imageRect1];
UIImageView *statusImageView = (UIImageView *) cell.accessoryView;
statusImageView.image= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我试图把这两个图像并排,但不知何故,在配件视图中没有任何东西。
发布于 2011-05-28 07:22:00
单元格accessoryView为UIView,而不是UIImageView。我不明白你为什么要画你的图片,因为你已经把它们打包在一起了。
为什么不呢:
UIImageView * image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"homesmall.png"]];
UIImageView * image2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"update.png"]];
[image1 setFrame:CGRectMake(0,0,20,20)];
[image2 setFrame:CGRectMake(20,0,20,20)];
UIView * cellAcc = [[UIView alloc] initWithFrame:CGRectMake(0,0,40,40)];
[cellAcc addSubview:image1];
[cellAcc addSubview:image2];
[cell setAccessoryView:cellAcc];
[image1 release];
[image2 release];
[cellAcc release];
https://stackoverflow.com/questions/6158476
复制相似问题