gpt4 book ai didi

objective-c - IOS11 UIContextualAction 放置图片颜色文字

转载 作者:太空狗 更新时间:2023-10-30 03:25:47 47 4
gpt4 key购买 nike

防止图片如何恢复真实颜色我现在放置的图片都是白色

- (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
}
}

并且在 trailingSwipeActionsConfigurationForRowAtleadingSwipeActionsConfigurationForRowAt

使用:

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/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com