如何在iOS8的UIAlertController中自定义UIAlertAction? [英] How can i customize UIAlertAction in UIAlertController for iOS8?

查看:557
本文介绍了如何在iOS8的UIAlertController中自定义UIAlertAction?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 UIAlertController 在Action表项中添加图像。我添加使用:

I need to add image in Action sheet item using UIAlertController. I add using:

UIImage *image = [UIImage imageNamed:@"icon.png"];
[alertAction setValue:image forKey:@"image"];

结果为:

问题在于:
<强>我需要图像&要集中对齐的文字并调整取消按钮的高度

我该怎么做,请分享一些代码。

How can i do that, please share some code.

谢谢!

推荐答案

好吧,这里 UIAlertAction 。您既不能更改图像的框架,也不能更改取消按钮的高度。

Well, here is the Runtime Header file for UIAlertAction. You can neither change the frame of image nor you can change the height of Cancel button.

那么解决方案是什么?

我能想到的唯一解决方案是制作自定义视图使用UIVisualEffect并显示/动画,如 UIActionSheet 。基本上你需要模仿 UIActionSheet

The only solution that I could figure is to make a custom view with UIVisualEffect and show/animate it like UIActionSheet. Basically you need to imitate UIActionSheet.

这就是说,我也欢迎其他解决方案。

That said, I would like to welcome other solutions as well.

这篇关于如何在iOS8的UIAlertController中自定义UIAlertAction?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆