ios - How can I implement a button in my app so every time a user presses it, the whole app default colour changes -
as title says, implement button when user presses once, general default colour changes. user presses button once , app theme becomes green , when pressed again, theme changes red , pressed again goes initial theme colour. have quick example? on google, when search above, how change colour of button. in advance!
yes hook action , whenever uibutton pressed call:
cgfloat red = (cgfloat)arc4random() / (cgfloat)rand_max; cgfloat blue = (cgfloat)arc4random() / (cgfloat)rand_max; cgfloat green = (cgfloat)arc4random() / (cgfloat)rand_max; uicolor *color = [uicolor colorwithred:red green:green blue:blue alpha:1.0]; self.view.backgroundcolor = color;
these lines of code generate random rgb numbers , turnes views color color.
to change other view controllers view:
yourviewcontroller.view.backroundcolor = color;
Comments
Post a Comment