这可能是一个简单的问题吗?
但我不知道如何在UIAlertView
的两个按钮之间放置空格。
所以请帮助我如何在UIAlertView的两个水平按钮之间放置空间。
UIAlertView的代码:
在我的 AlertView 中,我还添加了UITextFiewd
-(void)add:(UIBarButtonItem *) sender
{
self.alertView = [[UIAlertView alloc] initWithTitle:alertViewTitle message:@"\n\n" delegate:self cancelButtonTitle:@"Cancle"
otherButtonTitles:@"Save",nil];
self.alertTxtField = [[UITextField alloc]initWithFrame:CGRectMake(15, 55, 260, 35)];
self.alertTxtField.backgroundColor = [UIColor whiteColor];
self.alertTxtField.returnKeyType = UIReturnKeyDone;
self.alertTxtField.delegate = self;
[alertView addSubview:self.alertTxtField];
[alertView show];
}
我的屏幕截图:
提前致谢:)
答案 0 :(得分:0)
您无法使用UIAlertView
课程执行此操作。正如评论中提到的那样,您必须从头开始编写自己的类,或者在github等网站上使用在线找到的替代UIAlertView
类之一。快速谷歌搜索带来了这个课:CODialog。
您可能还会考虑是否真的想在那里放置空间,因为默认外观是用户在基本上所有其他应用中看到的内容。
答案 1 :(得分:0)
出于您的目的,我认为您需要像使用textfield一样向AlertView添加自定义按钮。您需要创建两个UIButtons
并设置适当的框架,并将其设置为警报视图subView
。您的方法将改变如下:
-(void)add:(UIBarButtonItem *) sender
{
self.alertView = [[UIAlertView alloc] init];
alertView.delegate = self;
alertView.title = alertViewTitle ;
self.alertTxtField = [[UITextField alloc]initWithFrame:CGRectMake(15, 55, 260, 35)];
// You need to allocate two buttons here and set the frame
//add it to alerts sub view
self.alertTxtField.backgroundColor = [UIColor whiteColor];
self.alertTxtField.returnKeyType = UIReturnKeyDone;
self.alertTxtField.delegate = self;
[alertView addSubview:self.alertTxtField];
[alertView show];
}