防止图片如何恢复真实颜色我现在放置的图片都是白色
- (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 的小更新:
class ImageWithoutRender: UIImage {
override func withRenderingMode(_ renderingMode: UIImage.RenderingMode) -> UIImage {
return self
}
}
并且在 trailingSwipeActionsConfigurationForRowAt
或 leadingSwipeActionsConfigurationForRowAt
使用:
if let cgImageX = UIImage(named: "x_blue_big")?.cgImage {
action.image = ImageWithoutRender(cgImage: cgImageX, scale: UIScreen.main.nativeScale, orientation: .up)
}
关于objective-c - IOS11 UIContextualAction 放置图片颜色文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46398910/