FirstApp,iphone开发学习总结1,UIview添加UIimage

作为第一个Tab,需要设置Title,在init内搞定:

- (id)init {
    self = [super init];
    if (self) {
        [self setTitle:@"图片展示"];
        UIImage *img = [UIImage imageNamed:@""];
        [[self tabBarItem] setImage:img];
    }
    return self;

此处未添加图片名称,所以TabBar只显示“图片展示”。

在- (void)viewDidLoad 中添加view add image 代码:

UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(50.050.048.048.0)];
imageview.image = [UIImage imageNamed:@"China.gif"];
[self.view addSubview:imageview];
[imageview release];

 使用UIImageView添加图片,然后再add至self.view。

原文地址:https://www.cnblogs.com/maxfong/p/2480143.html