UIImage(MemoryCacheCost)

@interface UIImage (MemoryCacheCost)

UIImage category for memory cache cost.

  • The memory cache cost for specify image used by image cache. The cost function is the bytes size held in memory. If you set some associated object to UIImage, you can set the custom value to indicate the memory cost.

    For UIImage, this method return the single frame bytes size when image.images is nil for static image. Return full frame bytes size when image.images is not nil for animated image. For NSImage, this method return the single frame bytes size because NSImage does not store all frames in memory.

    Note

    Note that because of the limitations of category this property can get out of sync if you create another instance with CGImage or other methods.

    Note

    For custom animated class conforms to SDAnimatedImage, you can override this getter method in your subclass to return a more proper value instead, which representing the current frame’s total bytes.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger sd_memoryCost;

    Swift

    var sd_memoryCost: UInt { get set }