Tôi có UITableView và tôi đã thêm hành động chỉnh sửa vào nó. Bây giờ tôi muốn thêm hình ảnh trên nhãn nút delete, như:Làm cách nào để thêm hình ảnh vào nút xóa UITableView?
Đây là mã của tôi:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let blockAction = UITableViewRowAction(style: .Normal, title: "Block") { (rowAction:UITableViewRowAction, indexPath:NSIndexPath) -> Void in
//TODO: Delete the row at indexPath here
}
blockAction.backgroundColor = UIColor.redColor()
return [blockAction]
}
Làm thế nào tôi có thể thêm hình ảnh vào nút của tôi Delete
?
@rmaddy nhưng làm thế nào các nhà phát triển khác làm điều đó? –
Có lẽ họ đang sử dụng lớp ô xem bảng tùy chỉnh của bên thứ ba và không sử dụng API chuẩn được cung cấp bởi 'UITableViewDelegate'. – rmaddy
tham khảo các câu hỏi này, bạn sẽ tìm thấy câu trả lời: http://stackoverflow.com/questions/20290766/change-the-color-of-default-red-color-delete-button-in-uitableviewcell-when- swip ---------------- http://stackoverflow.com/questions/29335104/how-add-custom-image-to-uitableview-cell-swipe-to -delete nếu bạn đang sử dụng iOS8 + –