imageNamed 與 imageWithContentsOfFile 區別

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 只適合用於小的圖片的讀取,或重複使用一張圖片的時候,而當加載一些比較大的圖片文件的時候,我們應當儘量避免使用這個方法.

還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.