imageView不能正确显示图片

是路不是陆 2015-11-21 05:46:21
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"welcome1"]];
image.backgroundColor = [UIColor colorWithRed:0.127 green:0.917 blue:0.170 alpha:0.835];
image.frame = CGRectMake(0, 0, 320,480);

[self.view addSubview:image];
}



welcome1是图片的名称,png格式,模拟器效果如图


适配不是主要问题,问题是图片为什么不显示出来?求解答,感谢
...全文
297 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
小王不加班 2015-11-26
  • 打赏
  • 举报
回复
你给一个UIImageView传了图片,又设置背景颜色是怎么回事?设了背景颜色,有赋了透明度值?
青酆 2015-11-25
  • 打赏
  • 举报
回复
@"welcome1"这个图片文件如果是png格式的你这样打名字是没问题的,除了png格式外的图片需要在名称后加类型如@"welcome1.jpg"
唐云T_yun 2015-11-23
  • 打赏
  • 举报
回复
试试 UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"welcome1.png"]];

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧