我在屏幕上有一张主图像,并且有一个"叠加" UIView放在它上面,背景颜色设置为Clear Color。我想在覆盖视图中动态放置其他图像,如下所示:
UIImage* m_icon = [[UIImage alloc]initWithContentsOfFile:@"icon.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:m_icon];
[m_OverlayView addSubview:imageView];
但是图标图像没有显示出来。我错过了什么?
答案 0 :(得分:0)
您可以尝试:
NSString *icon_path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];
UIImage* m_icon = [[UIImage alloc]initWithContentsOfFile:icon_path];
UIImageView *imageView = [[UIImageView alloc] initWithImage:m_icon];
[m_OverlayView addSubview:imageView];