Kau*_*hna 3 uitableview ios swift
我想在Swift中实现这个代码.我在Objective-C中从这些问题中获得了以下代码:
在滑动行或单击编辑按钮时,更改UITableViewCell中默认红色删除按钮的颜色
- (void)willTransitionToState:(UITableViewCellStateMask)state{
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
[deleteBtn setImage:[UIImage imageNamed:@"delete.png"]];
[[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
[deleteBtn release];
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何在Swift中实现这个方法.谁能帮助我?
我正在使用Xcode 7.3 Beta.
小智 7
swift tableview委托有新方法.试试这可能会解决您的问题.
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?{
let ackAction = UITableViewRowAction(style: .default, title: "Himanshu", handler: myFunction)
ackAction.backgroundColor = UIColor.orange
return [ackAction]
}
Run Code Online (Sandbox Code Playgroud)
现在您甚至可以修改删除功能
| 归档时间: |
|
| 查看次数: |
6201 次 |
| 最近记录: |