UIImageView 與 UIImage 區別


1.UIImageView不支持內部圖片平鋪(tile)

2.資源中的圖片要用小寫的,模擬器中可能不區分大小寫,但在真機中區分.

   [UIImage imageNamed:@""]; 在設備中區分大小寫

3.UIView沒有背景圖屬性,有背景色屬性.設置背景圖可以用addSubView(backgroundImage);,推薦的是設置背景色。

4.[UIImage imageNamed:@""];//它是有緩存特性的

  This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.

  On a device running iOS 4 or later, the behavior is identical if the device’s screen has a scale of1.0. If the screen has a scale of2.0, this method first searches for an image file with the same filename with an@2xsuffix appended to it. For example, if the file’s name isbutton, it first searches forbutton@2x. If it finds a 2x, it loads that image and sets thescale property of the returnedUIImage object to2.0. Otherwise, it loads the unmodified filename and sets thescale property to1.0.

   On iOS 4 and later, the name of the file is not required to specify the filename extension. Prior to iOS 4, you must specify the filename extension.

    可能在多次操作之后,應用經常發生內存警告從而導致自動退出的問題。定位之后發現是由於[UIImage imageNamed: @""]分配的圖像都沒有釋放引起的。而之前從官方的reference中得到的信息應該是[UIImage imageNamed:@""]分配的圖像系統會放到cache里面。而關於cache管理的規則就沒有明確的介紹。由此看來[UIImage imageNamed:]只適合與UI界面中小的貼圖的讀取,而一些比較大的資源文件應該盡量避免使用這個接口。

  5.  + (UIImage *)imageWithContentsOfFile:(NSString *)path  //這個方法does not cache the image object.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM