首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为附件视图组合2个图像

为附件视图组合2个图像
EN

Stack Overflow用户
提问于 2011-05-28 07:05:10
回答 1查看 353关注 0票数 0

我有2个图像,我想并排加入,并在配件视图中显示。

代码语言:javascript
运行
复制
 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();

我试图把这两个图像并排,但不知何故,在配件视图中没有任何东西。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-28 07:22:00

单元格accessoryView为UIView,而不是UIImageView。我不明白你为什么要画你的图片,因为你已经把它们打包在一起了。

为什么不呢:

代码语言:javascript
运行
复制
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];

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6158476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档