comment définir backgroundcolor de UIViewController dans iphone?comment définir backgroundcolor de UIViewController dans l'iphone?
12
A
Répondre
30
myViewController.view.backgroundColor = [UIColor redColor];
17
Dans IB, sélectionnez la vue dans le contrôleur de vue et cliquez sur le sélecteur de couleur de fond ou de le faire dans le code:
self.view.backgroundColor = [UIColor redColor];
0
Il y a aussi beaucoup plus claire façon d'écrire ce code:
[self.view setBackgroundColor:[UIColor redColor]];
C'est la différence entre la notation par points (les réponses précédentes) et la notation par méthode (ma réponse).
1
Pour Swift:
myViewController.view.backgroundColor = UIColor.blackColor()
self.view.backgroundColor = UIColor.blackColor()
Questions connexes
- 1. Définir backgroundColor de UITableViewCell dans UITableView groupé
- 2. Définir UITextView backgroundColor à clearColor l'anime - comment l'éviter?
- 3. SSRS TextBox BackgroundColor
- 4. BackGroundColor DateField
- 5. BackgroundColor d'un TextBox désactivé
- 6. Comment animer explicitement la backgroundColor d'une CALayer?
- 7. définir "par défaut" image d'arrière-plan UIViewController?
- 8. BackgroundColor des étiquettes UITableViewCellStyleSubtitle?
- 9. Comment définir correctement le titre navigationController d'un UIViewController?
- 10. UIModalPresentationFullScreen - backgroundColor derrière TransitionAnimation
- 11. la suppression backgroundcolor d'une vue dans Android
- 12. Impossible de définir un backgroundColor personnalisé avec une requête if dans ApplicationDidFinishLaunching
- 13. définir une couleur de fond d'un UIView d'un UIViewController
- 14. hover() backgroundColor problème
- 15. un moyen de définir la taille de mon UIViewController
- 16. Comment mettre à jour ImageButton BackgroundColor dans RemoteViews
- 17. Changer backgroundcolor pour UIButton IPhone
- 18. Modification de UITableView "BackgroundColor" de Index-Component
- 19. Référencement de UIViewController dans NSObject
- 20. comment obtenir backgroundcolor de iframe? peut-être iframe_window.document?
- 21. view.frame.size.height changer dans UIViewController
- 22. iPhone UIPickerView dans UIViewController
- 23. Comment remplacer la propriété "view" dans UIViewController?
- 24. Orientation dans UITabBarController + UIViewController
- 25. Problème de rotation UIViewController
- 26. Dessinez partiellement UIView en utilisant la backgroundColor
- 27. Mon RichTextBox change backgroundcolor lorsque Enabled est défini sur false
- 28. Comment initier UIViewController avec UIInterfaceOrientationLandscapeLeft?
- 29. Comment faire pour pousser UIViewController
- 30. NSString pour uiviewcontroller
est-il étrange que nous pour nos exemples de code à la fois choisi redColor? Heh ... – Jasarien
Oui, c'est peut-être parce que UIColor se termine par 'r' et c'est la couleur qui apparaît lorsque vous appuyez à nouveau sur r. – DyingCactus