如何更改 UIActionSheet 中按钮的突出显示颜色 - iPad

发布于 2025-01-02 15:58:31 字数 160 浏览 1 评论 0原文

我会更改 iPad 应用程序中 UIActionSheet 中按钮的突出显示颜色,因为我需要更改另一种颜色的默认蓝色...我只找到了使用未记录功能的解决方案,也许这是唯一的方法!但我会避免使用可能阻止我进入 App Store 的解决方案...

有任何想法或 github 项目可以链接吗?

I would change the highlighted color of buttons in UIActionSheet in iPad app, because I need to change the default blue in an another color... I only found solution that uses undocumented function, and maybe this is the only way to do this ! But I would avoid to use a solution that could prevent me to go on the App Store...

Any ideas or github project to link ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风铃鹿 2025-01-09 15:58:31

我这样解决:

   - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {

    //Gets an array af all of the subviews of our actionSheet
    NSArray *subviews = [actionSheet subviews];

    for (UIView *v in subviews) {
        if ([v isKindOfClass:[UIButton class]]) {
            UIButton *b = (UIButton*)v;
            [b setBackgroundImage:[UIImage imageNamed:@"backActionSheetHighlighted.png"] forState:UIControlStateHighlighted];
            [b setBackgroundImage:[UIImage imageNamed:@"backActionSheet.png"] forState:UIControlStateNormal];
        }
    }   
}

结果如下:

在此处输入图像描述

I solved in this way:

   - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {

    //Gets an array af all of the subviews of our actionSheet
    NSArray *subviews = [actionSheet subviews];

    for (UIView *v in subviews) {
        if ([v isKindOfClass:[UIButton class]]) {
            UIButton *b = (UIButton*)v;
            [b setBackgroundImage:[UIImage imageNamed:@"backActionSheetHighlighted.png"] forState:UIControlStateHighlighted];
            [b setBackgroundImage:[UIImage imageNamed:@"backActionSheet.png"] forState:UIControlStateNormal];
        }
    }   
}

the result is the following:

enter image description here

旧人九事 2025-01-09 15:58:31

点击链接,您将找到如何在操作表中添加子视图 http://www .ifans.com/forums/showthread.php?t=301851。然后在按钮中你可以尝试这个:

[myButton setBackgroundImageByColor:[UIColor greenColor] forState:UIControlStateHighlighted ];

follow the link, you will find how to add subview in action sheet http://www.ifans.com/forums/showthread.php?t=301851. Then in button you can try this:

[myButton setBackgroundImageByColor:[UIColor greenColor] forState:UIControlStateHighlighted ];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文