0

My problem is I have to change UIButton backgroundcolor on click and navigation controller move to next page.

  1. I don't need to use NSTimer to show button effect.
  2. I need to apply this effect for my application all buttons.
  3. I can't able to make my next view controller to wait for show this effect.
MaheThiru
  • 137
  • 9
  • See http://stackoverflow.com/questions/14523348/how-to-change-the-background-color-of-a-uibutton-while-its-highlighted – Yogendra Aug 01 '14 at 04:28

1 Answers1

0

If I understand what you're asking correctly, you want all buttons in your application to instantly change background colors upon a button click. You can do this using the UIButton's appearance.

In short, UIAppearance allows developers to easily keep visuals consistent throughout their applications. For more information on what it is and how to use it, click here.

Here's an example:

//Inside of an IBAction that a button clicks
[[UIButton appearance] setBackgroundColor:[UIColor redColor]];
rebello95
  • 8,486
  • 5
  • 44
  • 65
  • Thanks for your answer.I have changed the background color on button click and call the next view controller.But the changes can't able to see because of next page loaded before user see those changes. – MaheThiru Aug 01 '14 at 04:33
  • I've updated my answer with more info and a reference. Are you saying the user can't see the changes on the first view controller because the second view controller loads so quickly? If so, you'd have to delay your view controller's transition. – rebello95 Aug 01 '14 at 04:36
  • code: -(void) LoginAction:(UIButton *) button { button.backgroundColor=[uicolor redcolor]; [self.view addSubview:overlayView]; [NSTimer scheduledTimerWithTimeInterval:0.01 target: self selector: @selector(LoginActionTimer:) userInfo: nil repeats: NO]; } – MaheThiru Aug 01 '14 at 04:38
  • //login Timer Action -(void) LoginActionTimer:(NSTimer *) t { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; LoginViewController *viewController = (LoginViewController *)[storyboard instantiateViewControllerWithIdentifier:@"loginpage"]; [self.navigationController pushViewController:viewController animated:NO]; } – MaheThiru Aug 01 '14 at 04:39
  • You really should've just posted that as an edit to your question. What's the problem with that code? – rebello95 Aug 01 '14 at 04:40
  • i did like that above.But the background color not change to normal color until the NextviewController load.For that i have to add another timer function.So for a single button i have to add three functions. – MaheThiru Aug 01 '14 at 04:41
  • Did you use the code I posted in my answer? From the code you posted in the comment, it doesn't look like it. – rebello95 Aug 01 '14 at 04:46
  • both are samething..just i get reference for that color and applied. – MaheThiru Aug 04 '14 at 05:48