iphone sdk-带有图像的 UIAlertView 按钮

发布于 2024-08-06 05:15:12 字数 80 浏览 1 评论 0原文

您能告诉我是否可以使用 uiimage 视图作为 uialertview 按钮“文本”? 我无法通过谷歌搜索找到答案..

非常感谢

can you please tell me if it is possible to use an uiimage view as uialertview button "text"?
i was unable to find the answer googling..

thanks a lot

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

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

发布评论

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

评论(2

放血 2024-08-13 05:15:12

是的,这是可能的,但我不推荐它。您必须遍历 UIAlertView 的子视图,直到找到一个正确的类,我会假设 UIButton,并将您的 UIImageView 添加到顶部,如下所示:

for (UIView *v in [myAlertView subviews]) {
    if ([v isKindOfClass:[UIButton class]]) {
        //IF I AM THE RIGHT BUTTON
            [v addSubview:myUIImageView];
    }
}

要确定正确的按钮,您可能首先给它一些奇怪的文本,例如“foobar5”并测试每个按钮以查看这是否是其文本,如果是,则删除文本并添加 UIImageView。

Yes, it is possible, but I wouldn't recommend it. You'd have to run through the UIAlertView's subviews until you find one that is of the right class, I would assume UIButton, and add your UIImageView on top like this:

for (UIView *v in [myAlertView subviews]) {
    if ([v isKindOfClass:[UIButton class]]) {
        //IF I AM THE RIGHT BUTTON
            [v addSubview:myUIImageView];
    }
}

To determine the correct button, you might initially give it some odd text like "foobar5" and test each button to see if that is its text, and if so, remove the text and add the UIImageView.

氛圍 2024-08-13 05:15:12

您可以使用 unicode 字符,这些字符呈现为图标。
我在这里描述了它:
像 UIDocumentInteractionController 中一样将图像添加到 UIActionSheet 按钮

You can use unicode characters, which are rendered as icons.
I described it here:
Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

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