首页 > 代码库 > Xcode 设置图片全屏显示

Xcode 设置图片全屏显示

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.//

    UIImage *image = [UIImage imageNamed:@"initial_page_bg.jpg" ];

    UIImageView *imageView = [[UIImageView alloc]initWithImage:image];

    CGRect cr=[[UIScreen mainScreen] bounds];   //获取屏幕

    imageView.frame = CGRectMake(0, 0, cr.size.width, cr.size.height);  //全屏显示图片

    [imageView setContentMode:UIViewContentModeScaleToFill];  //拉伸模式

    [imageView setClipsToBounds:YES];

    [self.view addSubview:imageView];  //显示

    [self.view sendSubviewToBack:imageView];  //背景设置

    

}

 

Xcode 设置图片全屏显示