添加一个图片

//
//  ViewController.m
//  DemoProject
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 将图像初始化为一个对象
    UIImage *img = [UIImage imageNamed:@"nav_index"];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
    
    // 设置图像画布大小为图像大小
    imgView.frame = self.view.frame;
    [self.view addSubview:imgView];
}


@end

你可能感兴趣的:(添加一个图片)