本文介绍了iOS11 UIContextualAction放置图像颜色文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为防止图片变色我现在将图片放置为白色

To prevent the picture How to restore the real color I now place the image are white

- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0))
{

 UIContextualAction *deleteRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:nil handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL))
    {
        NSLog(@"------------------>%@",sourceView);
        completionHandler (YES);
    }];

    deleteRowAction.image = [UIImage imageNamed:@"heart"];

    UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteRowAction]];
         return config;


    return nil;

}

推荐答案

RSSReaderMaker解决方案可用于较小的更新Swift 5:

RSSReaderMaker solution work with small updates Swift 5:

class ImageWithoutRender: UIImage {
    override func withRenderingMode(_ renderingMode: UIImage.RenderingMode) -> UIImage {
        return self
    }
}

trailingSwipeActionsConfigurationForRowAtleadingSwipeActionsConfigurationForRowAt

使用:

if let cgImageX =  UIImage(named: "x_blue_big")?.cgImage {
     action.image = ImageWithoutRender(cgImage: cgImageX, scale: UIScreen.main.nativeScale, orientation: .up)
}

这篇关于iOS11 UIContextualAction放置图像颜色文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:15