我有两张图像,我想并排加入并在配件视图中显示。
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();
我试图把两个图像并排放在一边但不知道什么都没有进入附件视图。
答案 0 :(得分:1)
为什么不:
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];