我做了一個ActionSheet這樣的:如何禁用通過UIAlertViewController添加動作片按鈕操作 - (iOS版9/10)
現在我想改變顏色Cancel
而Delete
給予感覺他們是disabled
。
我能夠改變所有按鈕的顏色,但不是個人。
我試過使用類別,但我一直在得到warining
ActionSheet
是Depreciated
。代碼也沒有工作。
我寫了這個代碼:
- (void)setButton:(NSInteger)buttonIndex toState:(BOOL)enabled {
for (UIView* view in self.subviews)
{
if ([view isKindOfClass:[UIButton class]])
{
if (buttonIndex == 0) {
if ([view respondsToSelector:@selector(setEnabled:)])
{
UIButton* button = (UIButton*)view;
button.enabled = enabled;
}
}
buttonIndex--;
}
}
}
是否有可能使殘疾看看一些Action sheet
通過AlertViewController
提出的按鈕。
下面是我的代碼,以現在的動作片:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Action Sheet" message:@"Using the alert controller" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet.view setTintColor:[UIColor redColor]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// Cancel button tappped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// Distructive button tapped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Group 1" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// Distructive button tapped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// OK button tapped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
// Present action sheet.
[self presentViewController:actionSheet animated:YES completion:nil];
如果你想*禁用*的行爲,爲什麼你不有條件地忽略它們? – vadian
@vadian我必須向用戶展示這些是可用的選項。但是你不能選擇直到你滿足條件。 (如IAP) – Dalvik