为了防止图片如何还原本色,我现在把图片都放在白色的地方
- (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;
}发布于 2019-04-16 18:57:59
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)
}发布于 2018-07-19 20:33:55
您可以通过UIAppearance修改UIImage的通用tintColor来更改图片的颜色,例如:
UIImageView.appearance().tintColor = .yellow
但这会将该(默认)色调颜色应用于应用程序中的所有图像视图,因此您可以通过以下方式将其限制为表视图中的图像视图:
UIImageView.appearance(whenContainedInInstancesOf: [UITableView.self]).tintColor = .yellow
您还可以指定自己的UITableView子类(如果有)。
发布于 2019-03-22 16:43:02
我解决了这个问题。第一步是用随机名称声明UIImage的一个子类,并覆盖它的imageWithRenderingMode:方法。我想做这个
@implementation FakeImage
- (UIImage *)imageWithRenderingMode:(UIImageRenderingMode)renderingMode
{
return self;
}
@end第二步,在给UIContextualAction赋值时,使用这个类,注意使用initWithCGImage方法实例化。
UIContextualAction* action = xxxx;
action.image = [[FakeImage alloc] initWithCGImage:[UIImage imageNamed:@"zoo_icon_time"].CGImage scale:2 orientation:UIImageOrientationUp];把它做完。
https://stackoverflow.com/questions/46398910
复制相似问题