//注意這是加載圖片最簡單的方式女轿;這張圖片會(huì)被緩存到緩存中,加載速度較快岭粤;
UIImage *image = [UIImage imageNamed:@"1.jpg"];
//圖片的顯示是需要載體的邻吞;需要放在UIImageView;
UIImageView *imgView = [[UIImageView alloc]init];
//圖片顯示在屏幕上的大小是由載體控制的姥宝;
//現(xiàn)在把載體的大小設(shè)置成圖片的大小爸业,使用圖片的大小設(shè)置UIImageView的長寬其骄;
imgView.frame = CGRectMake(0, 0, 375, 667);
imgView.backgroundColor = [UIColor yellowColor];
[imgView setImage:image];
[self.view addSubview:imgView];
//圖片的顯示模式;
/*
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
*/
//內(nèi)容模式扯旷;
//注意:UIViewContentModeScaleToFill是默認(rèn)的顯示效果拯爽;
/*
UIViewContentModeScaleToFill:拉伸充滿整個(gè)載體;
UIViewContentModeScaleAspectFit:拉伸不改變比例钧忽,充滿最小的一邊毯炮;
UIViewContentModeScaleAspectFill:拉伸不改變比例逼肯,充滿最大的一邊;
*/
imgView.contentMode = UIViewContentModeScaleAspectFill;
原圖
UIViewContentModeScaleToFill:拉伸充滿整個(gè)載體桃煎;
UIViewContentModeScaleAspectFit:拉伸不改變比例篮幢,充滿最小的一邊;
UIViewContentModeScaleAspectFill:拉伸不改變比例为迈,充滿最大的一邊三椿;