Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 124

NorfolkAndGood
Aspiring developer
Profile
Posts: 41
Reg: Jul 17, 2013
Cirencester
410
09/19/13 12:08 PM (12 years ago)

NAD Advanced Quiz button colour fade change to colour switch

Hi Does anyone know if it is possible to modify the NAD advanced quiz such that the button colours don't fade in and out. I would prefer that they switch immediately to the appropriate colour and stay that colour until the next question. I have tried changing the animation timings, like this: if(selIndex == 2) { [UIView animateWithDuration:(_quizQuestionDelay/200) animations:^{ [_answerButton2 setBackgroundColor: self.quizButtonColorIncorrect]; } completion:^(BOOL finished) { [UIView animateWithDuration:(_quizQuestionDelay*1.2) animations:^{ [_answerButton2 setBackgroundColor : self.quizButtonColorAnswers]; }]; }]; } This causes the button to change colour almost immediately (due to the /200), but it still fades to the unanswered colour before changing to the next question. I have also changed the delay to *1.2 from /2 for the change back which almost works, but I would prefer to find the code to make it change colour immediately, pause for the allocated delay time and then be back to the correct colour for the next question. Any help would be appreciated, and Thank you Nad for your help previously, it did lead to me buying your code.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
09/19/13 12:46 PM (12 years ago)
The trick is to get rid of the animations entirely. if(selIndex == 2) { [_answerButton2 setBackgroundColor: self.quizButtonColorIncorrect]; } and then finding a differnt place to set put the color back to normal putting this somewhere in the transitionQuestions method might work. [_answerButton2 setBackgroundColor : self.quizButtonColorAnswers];
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
09/19/13 12:47 PM (12 years ago)
And thanks for buying my plugin N:D
 
NorfolkAndGood
Aspiring developer
Profile
Posts: 41
Reg: Jul 17, 2013
Cirencester
410
like
09/19/13 12:50 PM (12 years ago)
Thanks for this. Won't this cause it to change colour and change back immediately before the delay has passed? Do I need to add something in between to make the delay hold the colour? Thanks again
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
09/19/13 12:54 PM (12 years ago)
I edited the original some.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
09/19/13 01:03 PM (12 years ago)
So in the transitionQuestion method you will put the color back to normal after the fade out but before the fade in. // call animations [UIView animateWithDuration:1.0 animations:firstAnimation completion:^(BOOL finished) { [self setQuestionsAndAnswers]; // put the color back here [UIView animateWithDuration:1.0 animations:secondAnimation completion:^(BOOL finished) { if (_enableResetTimer) { _totalSeconds = 0; } }];
 
NorfolkAndGood
Aspiring developer
Profile
Posts: 41
Reg: Jul 17, 2013
Cirencester
410
like
09/19/13 01:12 PM (12 years ago)
That sorts it. Thank you very much.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.