1 Replies - 3600 Views - Last Post: 05 June 2013 - 06:16 AM

#1 Pool4me  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-May 13

fade out label in xcode

Posted 14 May 2013 - 03:10 AM

Hi everyone,

I'm doing my best to self-teach myself to write code for an IOS application but I'm still very new to this and the language is very daunting.. My aim is to make a "Quiz based application" to help people study for exams.
I have written the main code to randomly select between categories and then between a few thousand questions. And also to display the question along with 4 wrong and 1 correct answer. Pressing an answer will take you back to the category choice. However before this happens I would like to highlight the correct answer somehow.

I've tried to make the correct answer fade away using

-(IBAction) fade {
[UIView beginAnimations:nil context:Null];
[UIView setAnimationDuration:2.0];
[label setAlpha:0];
[UIView commitAnimations];

This however just causes the correct answer to fade out before the user has time to answer the question.
I don't really mind how the answer is highlighted. As long there is some indication as to which answer was correct after the user has chosen.

Thanks very much for any help.

And I apologise in advance for my lack of knowledge.

Is This A Good Question/Topic? 0
  • +

Replies To: fade out label in xcode

#2 RIRedinPA  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 05-June 13

Re: fade out label in xcode

Posted 05 June 2013 - 06:16 AM

You want to use UIViews animateWithDuration method and enter the wonderful world of blocs!

[UIView animateWithDuration:0.5 delay2.0 options:UIViewAnimationOptionCurveEaseIn
            viewToAnimate.alpha = 0.0;

         completion:^ (BOOL finished) {
             //do some stuff here once animation is completed if you want 

What's happening here: you set the speed of the animation (0.5), how long a delay you want before the animation begins (2 seconds), options (in this case ease in, which means it wil begin slow and then speed up and then in the animations bloc which view you want the animation to happen on and what that animation is (in this case taking the alpha to 0.0). There is also a completion bloc where you can do some task (I like to do some housekeeping here - depending on the app and required functionality I might move the hidden view off screen)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1