2010-08-06 7 views
2

j'essaie de changer la couleur de fond de mon actionsheet, je viens d'utiliser la méthode:couleur de fond de uiactionsheet

[actionSheet setBackgroundColor: [UIColor colorWithRed: 30 vert: 30 bleu: 30 alpha: 0,5]];

et je l'ai mis dans la willPresentActionSheet. Mais la couleur de fond ne change pas, pourquoi?

Répondre

1

Vous pouvez vous référer à un stackoverflow post existant qui parle de techniques pour modifier la coloration de la feuille d'action.

12
  • ajouter QuartzCore.framework
  • délégué set pour votre actionsheet
  • style jeu pour actionsheet: UIActionSheetStyleBlackTranslucent
  • méthode de remplacement willPresentActionSheet
#import "QuartzCore/QuartzCore.h" 
... 

yourActionSheet.delegate = self; 
yourActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; 
... 

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet { 
    [[actionSheet layer] setBackgroundColor:[UIColor redColor].CGColor]; 
} 
+0

Cela ne fonctionne pas lorsque la feuille d'action est présenté à partir de la barre d'onglets: [actionSheet showFromTabBar: sel f.tabBarController.tabBar], mais fonctionne lorsqu'il est présenté depuis la vue: [actionSheet showInView: self.tabBarController.view]. –

+1

Super .... +1 !! – TheTiger

+0

+ 1 pour une réponse simple et courte .. :) –