UIContextualAction的颜色会变成白色的解决方案
使用:
#import "NoChangeColorImage.h"
UIContextualAction *deleteRowAction = xxxxx;
deleteRowAction.image = [UIImage imageNamed:@"bookmark_delete"].noChangeImage;
实现
// NoChangeColorImage.h
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface NoChangeColorImage : UIImage
@end
@interface UIImage(NoChangeColorImage)
- (NoChangeColorImage *)noChangeImage;
@end
NS_ASSUME_NONNULL_END
// NoChangeColorImage.m
#import "NoChangeColorImage.h"
@implementation NoChangeColorImage
- (UIImage *)imageWithRenderingMode:(UIImageRenderingMode)renderingMode{
return self;
}
@end
@implementation UIImage(NoChangeColorImage)
- (NoChangeColorImage *)noChangeImage{
return [[NoChangeColorImage alloc] initWithCGImage:self.CGImage scale:[UIScreen mainScreen].nativeScale orientation:UIImageOrientationUp];
}
@end