UIActionSheetボタンの色を変更するにはどうすればよいですか?UIActionSheetボタンの色
16
A
答えて
34
のiOS 8(UIAlertController)
それはあなたがUIAlertControllerを使用している場合行うに超簡単です。 UIAlertControllerのビューで色合いの色を変更するだけです。
[alertController.view setTintColor:[UIColor red];
のiOS 7(UIActionSheet)
私は正常にこの簡単な方法を使って、テキストの色を変更します。
- (void) changeTextColorForUIActionSheet:(UIActionSheet*)actionSheet {
UIColor *tintColor = [UIColor redColor];
NSArray *actionSheetButtons = actionSheet.subviews;
for (int i = 0; [actionSheetButtons count] > i; i++) {
UIView *view = (UIView*)[actionSheetButtons objectAtIndex:i];
if([view isKindOfClass:[UIButton class]]){
UIButton *btn = (UIButton*)view;
[btn setTitleColor:tintColor forState:UIControlStateNormal];
}
}
}
[showInView]、すべてのボタンが、キャンセルボタンが着色される前に、あなたはそれを呼び出す場合は、
[actionSheet showInView];
を呼び出す後にこの を実行することを確認します。これが誰かを助けることを願って!
1
残念ながら、ドキュメント化されていないAPIを使用しないと、UIActionSheetでボタンの色を変更する公式の方法はありません。 UIActionSheetコントロールをサブクラス化する場合、これをカスタマイズすることができます。
この例を参照してください:http://blog.corywiles.com/customizing-uiactionsheet-buttons
7
私はUIActionSheet内側のボタンのフォント、色とイメージをカスタマイズすることができます子クラスUICustomActionSheetを、作成しています。それは絶対にAppStoreのために安全である、あなたは次のリンク上で、このクラスのコードを見つけることができます。
https://github.com/gloomcore/UICustomActionSheet
がそれをお楽しみください!
1
私たちは背景イメージを使ってそれを行うことができます。私はそれが最も簡単な方法だと思う。
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Actionsheet" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet addButtonWithTitle:@"Button 1"]; //Blue color
[actionSheet addButtonWithTitle:@"Button 2"];
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet addButtonWithTitle:nil];
[actionSheet setCancelButtonIndex:2];
[actionSheet setDestructiveButtonIndex:1];
[actionSheet showInView:self.view];
UIButton *button = [[actionSheet subviews] objectAtIndex:1];
UIImage *img = [button backgroundImageForState:UIControlStateHighlighted];//[UIImage imageNamed:@"alert_button.png"];
[button setBackgroundImage:img forState:UIControlStateNormal];
0
あなたはこれをしなかったのあなたは簡単に次のコード
アップル
UIActionSheetDelegate
プロトコルのドキュメント
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *_currentView in actionSheet.subviews)
{
if ([_currentView isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)_currentView;
[button setTitleColor:YOUR_COLOR forState:UIControlStateNormal];
}
}
}
関連する問題
- 1. 複数の赤色/破壊ボタンUIActionSheet
- 2. UIActionSheet内の[Undo]ボタン
- 3. 緑色のUIActionSheetボタンを作成しますか?
- 4. UIActionSheetの破壊ボタンのガイドライン
- 5. UIPickerViewのUIActionSheetと前のボタン
- 6. UIActionSheetボタンは、新しいビュー
- 7. UIActionSheetのボタンのハイライトされた色を変更する方法 - iPad
- 8. UIActionsheetのボタンを変更するには
- 9. ビューを表示するUIActionSheetボタン
- 10. UIActionSheetボタン新しいビューをロードする
- 11. iOS 5 UIActionSheetボタンからのビューの読み込み
- 12. UIActionSheetカスタマイズ
- 13. UIActionSheet buttonIndex
- 14. カスタマイズUIActionSheet
- 15. UIActionSheetの作成
- 16. UIActionSheetのボタンとアクションを動的に変更する
- 17. iphoneのUIActionSheetにボタンを動的に追加するには
- 18. UIActionSheetのボタンを無効にする方法は?
- 19. UIActionSheetボタンのデフォルト言語を変更する方法は?
- 20. iPadのUIActionSheetのキャンセルボタン
- 21. ボタンの色Tkinter
- 22. ボタンの色エラー
- 23. UITabBarボタンからiPhone UIActionSheetが呼び出される
- 24. UIActionSheet addButtonWithTitle:正しい順序でボタンを追加しない
- 25. UIActionSheetとUIView
- 26. メインビューaにUIActionsheet
- 27. UIActionSheet showFromRectオートローテーション
- 28. UIActionSheetを表示
- 29. UIActionSheet cancelButtonTitle ipad
- 30. UIActionSheet UI仕様
これは選択された回答でなければなりません。よくやった。 – dclowd9901
@ dclowd9901ありがとう! ;) – Rymnel
ありがとうございます - iOS7でもうまくいきます。 – kmorris