美文网首页
imageNamed 与 imageWithContentsOf

imageNamed 与 imageWithContentsOf

作者: kyson老师 | 来源:发表于2021-07-28 18:16 被阅读0次

    Use the imageNamed:inBundle:compatibleWithTraitCollection: method (or the imageNamed: method) to create an image from an image asset or image file located in your app’s main bundle (or some other known bundle). Because these methods cache the image data automatically, they are especially recommended for images that you use frequently.
    Use the imageWithContentsOfFile: or initWithContentsOfFile: method to create an image object where the initial data is not in a bundle. These methods load the image data from disk each time, so you should not use them to load the same image repeatedly.

    imageNamed 与 imageWithContentsOfFile

    来自:https://developer.apple.com/documentation/uikit/uiimage?language=objc

    小结

    imageNamed 只适合用于小的图片的读取,或重复使用一张图片的时候,而当加载一些比较大的图片文件的时候,我们应当尽量避免使用这个方法.

    相关文章

      网友评论

          本文标题:imageNamed 与 imageWithContentsOf

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