xcode 带有垂直按钮的 UIAlertview

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4776169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:07:59  来源:igfitidea点击:

UIAlertview with vertical buttons

iphonexcodeios4

提问by Surjit Joshi

Possible Duplicate:
Is it possible to lay out 2 buttons vertically on UIAlertView?

可能的重复:
是否可以在 UIAlertView 上垂直布置 2 个按钮?

Is it possible to create UIAlertview with vertical buttons?

是否可以使用垂直按钮创建 UIAlertview?

回答by Surjit Joshi

Its too simple... If you display more than 2 buttons in UIAlertView, then it iOS directly stacks the buttons. Try to add more buttons.

太简单了...如果你在UIAlertView中显示2个以上的按钮,那么iOS直接把按钮堆叠起来。尝试添加更多按钮。

回答by TomSwift

I think you mean "stacked" buttons vs. side-by-side buttons.

我认为您的意思是“堆叠”按钮与并排按钮。

When there are only two buttons, UIAlertView places them side-by-side. When there are 3 or more buttons, they are presented "stacked".

当只有两个按钮时,UIAlertView 将它们并排放置。当有 3 个或更多按钮时,它们会“堆叠”显示。

回答by YenaMom

I had tried to write the answer as the following, but I found that the author of TSAlertView is here.

我曾尝试将答案写成如下,但我发现 TSAlertView 的作者在这里。

See TSAlertView project

查看TSAlertView 项目

回答by WrightsCS

No, there are no vertical buttons for the UIAlertView class. you can however create your own implementation of a UIAlertView and custom create vertical buttons.

不,UIAlertView 类没有垂直按钮。但是,您可以创建自己的 UIAlertView 实现并自定义创建垂直按钮。

To replicate UIActionSheet, you only use 1 button.

要复制 UIActionSheet,您只需使用 1 个按钮。

回答by Rich

alert views are just like any UIView, you can search their view hierarchy and obtain their buttons then set their transform property to CGAffineTransformMakeRotation(M_PI_2). You'll need to modify the frames before you do the transform or else the buttons will be partly outside the image thats behind them. You might also want to change out the view behind the buttons since it won't look like it goes with the buttons.

警报视图就像任何 UIView 一样,您可以搜索它们的视图层次结构并获取它们的按钮,然后将它们的转换属性设置为CGAffineTransformMakeRotation(M_PI_2)。您需要在进行转换之前修改框架,否则按钮将部分位于它们后面的图像之外。您可能还想更改按钮后面的视图,因为它看起来与按钮不一样。