2017-09-06 10 views
-1

変更したいUIAlertControllerUIAlertAction TextColorユーザーがアクションを選択すると、チェックマークイメージが表示されます。UIAlertController UIAlertActionの色を変更し、チェックマークの署名を追加するには?

私は正常に表示することができますUIAlertController。しかし、私はこれをどのように達成できますか?

私に何か提案してもらえますか、それを手伝ってもらえますか? ありがとう

答えて

-1

これを任意の3rdPartyライブラリ

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; 

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){ 
     NSLog(@"Cancle Tapped"); 
     [alertController dismissViewControllerAnimated:YES completion:nil]; 
    }]; 

    [alertController addAction:cancelAction]; 

    UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", @"YES action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ 
     NSLog(@"Yes Button Tapped"); 
    }]; 

    // Add CheckMark And Change CheckMark Color 
    [yesAction setValue:YOUR_COLOUR forKey:@"titleTextColor"]; 
    [yesAction setValue:YOUR_COLOUR forKey:@"imageTintColor"]; 

    [alertController addAction:yesAction]; 

    UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"NO", @"NO action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ 

    }]; 

    // Add CheckMark And Change CheckMark Color 
    [noAction setValue:YOUR_COLOUR forKey:@"titleTextColor"]; 
    [noAction setValue:YOUR_COLOUR forKey:@"imageTintColor"]; 
    [alertController addAction:noAction]; 

    [self presentViewController:alertController animated:YES completion:nil]; 

を使用する必要はありません試してみて、あなたは、デフォルトでチェックマークを任意のボタンを設定したい場合は、これを追加するよりも。

[yesAction setValue:@true forKey:@"checked"]; 
0

UIAlertActiontextcolorを無効にすることはできません。独自のビューを作成し、ニーズに合わせて提示する必要があります。必要なものを実現するためのサードパーティライブラリがあります。

+0

あなたの意見が分かりません。 –

+1

アプリが拒否される可能性があるため、プライベートAPI /プロパティをオーバーライドすることはお勧めできません。それについては、Appleのマニュアルを参照してください。そのため、textcolorを変更する代わりに、UIAlertControllerのように動作する独自のビューを作成します。 UIAlertControllerのルックアンドフィールを得るために、サードパーティライブラリを使用することができます。私はあなたが同意することを望む。 –

関連する問題