| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // UIImage+Addtions.m
- // JasonDevelop
- //
- // Created by Jason Lee on 3/10/15.
- // Copyright (c) 2015 JasonDevelop. All rights reserved.
- //
- @import ObjectiveC.runtime;
- #import "UIImage+Addtions.h"
- @implementation UIImage (Addtions)
- + (void)load {
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- Class class = [self class];
- Method imageNamed = class_getClassMethod(class, @selector(imageNamed:));
- Method imageNamedCustom = class_getClassMethod(class, @selector(imageNamedCustom:));
- method_exchangeImplementations(imageNamed, imageNamedCustom);
- });
- }
- + (UIImage *)imageNamedCustom:(NSString *)name {
- UIImage *image = [self imageNamedCustom:name];
- [image setFileName:name];
- return image;
- }
- - (NSString *)fileName {
- return objc_getAssociatedObject(self, _cmd);
- }
- - (void)setFileName:(NSString *)fileName {
- objc_setAssociatedObject(self, @selector(fileName), fileName, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- }
- @end
|