簡體   English   中英

在UISwipeActionsConfiguration iOS 11 - Xamarin / Swift中更改文本和圖像的顏色

[英]Change color for a text and image in a UISwipeActionsConfiguration iOS 11 - Xamarin / Swift

我有這個UISwipeActionsConfiguration for iOS 11這個代碼看起來像

在此輸入圖像描述

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

存在修改文本和圖像顏色的方法? 因為我沒有想法,我嘗試在用戶滑動時在單元格上創建一個ImageView,但圖像位於滑動視圖的后面。 感謝您的幫助,我希望您能幫助我。

實際上修改UISwipeActionsConfiguration以更改文本的顏色,並且無法使用API​​來處理圖像。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM