2015-05-15 38 views
2

我有一个带有文本字段的UIAlertView。有人能帮我解决我应该怎么做才能在他们之间留下一些空间吗?警报视图中的两个文本字段,它们之间有空格

newBoatAlert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput; 

UITextField * alertTextField1 = [newBoatAlert textFieldAtIndex:0]; 
alertTextField1.keyboardType = UIKeyboardTypeDefault; 
alertTextField1.placeholder = @"Name"; 

UITextField * alertTextField2 = [newBoatAlert textFieldAtIndex:1]; 
alertTextField2.frame=CGRectMake(alertTextField1.frame.origin.x, alertTextField1.frame.origin.y+alertTextField1.frame.size.height+10, alertTextField1.frame.size.width, alertTextField1.frame.size.height+40); 

alertTextField2.keyboardType = UIKeyboardTypeDefault; 
alertTextField2.placeholder = @"Description"; 
alertTextField2.secureTextEntry=NO; 

现在看起来是这样的:

enter image description here

+2

你将需要为此创建自定义控件。 –

+3

你不应该再使用UIAlertView,它已经在iOS 8中被弃用了。https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertView_Class/ – LoVo

+0

感谢兄弟 –

回答

1

不能编辑内置UIAlertView风格,苹果提供了(至少在没有肮脏的黑客将可能被打破下一个iOS版本)。

如果要定制警报的外观(例如在文本字段之间添加空格),您应该创建自己的UIView子类并从头开始实施您自己的警报UI。

另外,如果您确实选择使用Apple内置的警报而不是自行滚动,UIAlertView现在已被弃用,您应该使用UIAlertController来代替。它为文本框提供了相同的功能,并为按钮提供了更多的自定义选项(尽管如此,仍然无法更改布局)。

相关问题