更改 iOS 中对话框按钮的颜色?

Change the color of the dialog buttons in iOS?

有没有办法更改 iOS 中对话框按钮的文本颜色?

我的意思是底部的 OK/Cancel 按钮用于 alerts/confirm 对话框等

如果是本机代码,那也可以。

如果您想在 IOS 上实现此目的,您将需要使用本机代码,具体方法如下:

if (isIOS) {
            var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle("title", "message", UIAlertControllerStyle.ActionSheet);
            
            // Here are some premade styling. The destructive by default is red on IOS. You can select default for them all or use existing.
            var editAction = UIAlertAction.actionWithTitleStyleHandler("Edit", UIAlertActionStyle.Default, (arg: UIAlertAction) => {
                //code implementation here
            });
            var deleteAction = UIAlertAction.actionWithTitleStyleHandler("Delete", UIAlertActionStyle.Destructive, (arg: UIAlertAction) => {
                //code implementation here
            });
            var cancelAction = UIAlertAction.actionWithTitleStyleHandler("Cancel", UIAlertActionStyle.Cancel, (arg: UIAlertAction) => {
                //code implementation here
            });
        
            alertController.addAction(editAction);
            alertController.addAction(deleteAction);
            alertController.addAction(cancelAction);

            // This is how you can force change the color of the title text on the actions (buttons).
            alertController.view.tintColor = new Color("#FF0000").ios; // Color is a class in Nativescript, if we you want the Native IOS value, this is how you do it.

            var currentPage = topmost().currentPage;
            var viewController: UIViewController = currentPage.ios;
            viewController.presentModalViewControllerAnimated(alertController, true);
        }

确保您导入了所需的内容:

import { isIOS, Color } from 'tns-core-modules/ui/page/page';
import { topmost } from 'tns-core-modules/ui/frame';

您可以通过更改默认 alertController.view 设置来自定义其他样式。因此,只需尝试最适合您的用例即可。