美文网首页
imageWithContentsOfFile

imageWithContentsOfFile

作者: 拳头vs板凳 | 来源:发表于2017-03-01 21:51 被阅读0次

if (iOS7)

{

imgName = [imgName stringByAppendingString:@"@2x.png"];

}

NSString *filePath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:imgName];

imgView.image = [UIImage imageWithContentsOfFile:filePath];

iOS8以后,imageWithContentsOfFile可以通过filename不带后缀来获取图片,例如"xx"可以获取到xx@2x.png或者xx@3x.png图片。

iOS7只能通过带后缀的全称来获取图片

相关文章

网友评论

      本文标题:imageWithContentsOfFile

      本文链接:https://www.haomeiwen.com/subject/kebcgttx.html