我在
中创建了UITableViewRowAction
的实例
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
并且在触发此行操作时我有一个处理程序块:
handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
您有一个可以使用的行动作参数,因此您不会创建保留周期并且您有一个索引路径。我已经尝试设置这个新行动作的backgroundColor
:
[action setBackgroundColor:[UIColor greenColor]];
但这并没有改变任何事情。我还在行动的按钮对象上尝试了setNeedsDisplay
,但没有任何运气。
知道在行动作仍然可见的情况下如何更改backgroundColor
?感谢
答案 0 :(得分:2)
这是我的相同实现,效果很好。它也应该解决你的问题..
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *one = [UITableViewRowAction rowActionWithStyle:0 title:@"one" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
NSLog(@"my first action");
}];
UITableViewRowAction *two = [UITableViewRowAction rowActionWithStyle:1 title:@"two" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
NSLog(@"my second action");
}];
UITableViewRowAction *three = [UITableViewRowAction rowActionWithStyle:1 title:@"three" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
NSLog(@"my third action");
}];
one.backgroundColor = [UIColor purpleColor];
two.backgroundColor = [UIColor greenColor];
three.backgroundColor = [UIColor brownColor];
return @[one, two, three];
}