首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在UISwipeActionsConfiguration iOS 11 - Xamarin / Swift中更改文本和图像的颜色

在UISwipeActionsConfiguration iOS 11 - Xamarin / Swift中更改文本和图像的颜色
EN

Stack Overflow用户
提问于 2017-10-12 13:17:23
回答 1查看 1.5K关注 0票数 7

我有这个UISwipeActionsConfiguration for iOS 11,这段代码看起来像

代码语言:javascript
复制
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,但是图像在滑动视图的后面。谢谢你的帮助,我希望你能帮我这个忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-06 13:31:25

实际上,修改UISwipeActionsConfiguration以改变文本的颜色是不可能的,使用API的图像是不可能的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46710664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档