2015-11-26 8 views
11

मेरे पास एक UITableView है और मैंने इसमें संपादन क्रियाएं जोड़ दी हैं। अब मैं हटाना बटन लेबल ऊपर छवि को जोड़ने के लिए, के रूप में चाहते हैं:UITableView हटाएं बटन पर छवि कैसे जोड़ें?

enter image description here

यह मेरा कोड है:

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

मैं अपने Delete बटन पर छवि जोड़ सकते हैं कैसे?

+0

@rmaddy जाने पर कैसे अन्य डेवलपर्स कि क्या ज़रूरत है? –

+0

शायद वे एक तृतीय पक्ष कस्टम टेबल व्यू सेल क्लास का उपयोग कर रहे हैं और 'UITableViewDelegate' द्वारा प्रदान की गई मानक API का उपयोग नहीं कर रहे हैं। – rmaddy

+1

इस प्रश्न का संदर्भ लें, आपको अपना उत्तर मिल जाएगा: http://stackoverflow.com/questions/20290766/change-the-color-of-default-red-color-delete-button-in-uitableviewcell-when- ---------------- http://stackoverflow.com/questions/29335104/how-add-custom-image-to-uitableview-cell-swipe-to -delete यदि आप iOS8 + –

उत्तर

0

आप इसे पूरा करने के लिए एक स्वाइप करने योग्य टेबलव्यूसेल लागू कर सकते हैं जहां आप संपादन कार्यों के लिए कस्टम बटन लागू कर सकते हैं। इस पर बहुत सारे ट्यूटोरियल हैं। चेक एक नीचे:

https://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views

1

आप पृष्ठभूमि रंग पर विशेष छवि का उपयोग करें और के लिए '\ n' प्रतीक का उपयोग कर सकते नीचे पाठ

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { 

    let blockAction = UITableViewRowAction(style: .normal, title: "\nBlock") { (rowAction:UITableViewRowAction, indexPath:IndexPath) -> Void in 
     //TODO: Delete the row at indexPath here 
    } 
    blockAction.backgroundColor = UIColor(patternImage: UIImage(named: "delete_background")!) 

    return [blockAction] 
} 
संबंधित मुद्दे