2017-10-12 12 views
7

मैं आईओएस 11 के लिए इस UISwipeActionsConfiguration है इस कोड को लगता है किरंग बदलें - Xamarin/स्विफ्ट

enter image description here

public override UISwipeActionsConfiguration GetLeadingSwipeActionsConfiguration(UITableView tableView, NSIndexPath indexPath) 
     { 
      var definitionAction = ContextualDefinitionAction(indexPath.Row); 
      var flagAction = ContextualFlagAction(indexPath.Row); 
      var leadingSwipe = UISwipeActionsConfiguration.FromActions(new UIContextualAction[] { flagAction, definitionAction }); 

      leadingSwipe.PerformsFirstActionWithFullSwipe = false; 
      return leadingSwipe; 
     } 


    public UIContextualAction ContextualDefinitionAction(int row) 
    { 
     string word = words[row]; 

     var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, 
                  "Definition", 
                  (ReadLaterAction, view, success) => { 
                   var def = new UIReferenceLibraryViewController(word); 

                   var alertController = UIAlertController.Create("No Dictionary Installed", "To install a Dictionary, Select Definition again, click `Manage` on the next screen and select a dictionary to download", UIAlertControllerStyle.Alert); 
                   alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); 

                   if (UIReferenceLibraryViewController.DictionaryHasDefinitionForTerm(word) || hasViewedAlert == true){ 
                    PresentViewController(def, true, null); 
                    success(true); 
                   }else{ 
                    PresentViewController(alertController, true, null); 
                    hasViewedAlert = true; 
                    success(false); 
                   } 
                  }); 
     action.BackgroundColor = UIColor.Orange; 
     return action; 
    } 

    public UIContextualAction ContextualFlagAction(int row) 
    { 
     var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, 
                    "Flag", 
                    (FlagAction, view, success) => { 
                     var alertController = UIAlertController.Create($"Report {words[row]}?", "", UIAlertControllerStyle.Alert); 
                     alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); 
                     alertController.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Destructive, null)); 
                     PresentViewController(alertController, true, null); 

                     success(true); 
                    }); 

     action.Image = UIImage.FromFile("feedback.png"); 
     action.BackgroundColor = UIColor.Blue; 

     return action; 
    } 

का रंग बदलने के लिए एक रास्ता मौजूद पाठ और छवि? क्योंकि मेरे पास कोई विचार नहीं है, मैं उपयोगकर्ता को स्वाइप करते समय सेल पर एक छवि दृश्य बनाने का प्रयास करता हूं लेकिन छवि स्वाइप के दृश्य के पीछे होती है। मदद के लिए धन्यवाद और मुझे उम्मीद है कि आप इसके साथ मेरी मदद कर सकते हैं।

+0

मुझे लगता है कि आप पाठ के बजाय छवि का उपयोग कर सकते हैं, क्योंकि टूल (फ़ोटोशॉप इत्यादि) के साथ छवि का रंग बदलना आसान है। –

उत्तर

0

वास्तव में UISwipeActions कॉन्फ़िगरेशन को संशोधित करने के लिए पाठ का रंग बदलने और API के साथ छवि संभव नहीं है।

संबंधित मुद्दे