2011-06-11 52 views
1

我想要使UIAlertView具有两个按钮相同的两种颜色。我不希望它有一个取消按钮:UIAlertView显示两个按钮是相同的颜色

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Place Call" 
                message:@"Would you like to call this contact's Home or Cell phone?" 
                delegate:self 
                cancelButtonTitle:nil 
                otherButtonTitles:@"Cell",@"Home",nil]; 

但这并没有把戏。 “单元格”按钮像蓝色,“主页”按钮像灰色。

+0

原因是因为主页按钮是默认按钮。我现在不想改变这种情况,_defaultButton ivar是私人的。 – zaph 2011-06-12 03:53:16

回答

0

我认为你可以使用objectAtIndex:找到按钮(可能需要一些猜测/试验),并通过CGRect或自定义视图更改颜色。我不知道如何工作,但我认为这是值得一试的。也许与layer?让我知道如果它不起作用。

0

如果您愿意,请尝试自定义AlertView。创建一个视图并放置多少个按钮,然后调整颜色。 然后当你想提醒你的用户时显示这个视图。

+0

你能举个例子吗? – CodeGuy 2011-06-12 06:19:32

+0

点击这里创建一个视图:http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html然后在自定义类型中创建自己的UIButton,它是:http: //developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html然后把你的按钮放在View上。 – 2011-06-12 11:01:51

相关问题