Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:49:24+00:00 2026-05-27T06:49:24+00:00

I have a global variable p. I have a function that draws (or redraws)

  • 0

I have a global variable p.
I have a function that draws (or redraws) my complex UIView objects depending on the value of this global variable.
When I increase p my uiview objects needs to be redrawed. I need this be done using animation.

double pInitialValue=0.5;
double pNewValue=1.0;

//somewhere before animation we must call [self redraw] to draw our view with p=pInitialValue;

//then, when we call animate function.
//we change p to pNewValue
//and every step must be redrawed using [self redraw]

p=pNewValue; //using animation p must slowly grow from pInitialValue to pNewValue
[self redraw]; //and ofcourse user must see every step of animation so we need to call redraw function

for example I need an animation with duration 4.
That means that during this 4 seconds my p must grow from pInitialValue to pNewValue and in every step my redraw function must be called

Help me, please. How can it be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:49:25+00:00Added an answer on May 27, 2026 at 6:49 am

    You can use a timer to increase your p value. Do that like this: have an instance variable in your class defined like

    NSTimer *timer;
    

    After that just before you want your animation to happen do:

    CGFloat timerInterval = 1 / 30; // This means 30 frames per second. Change this as you want.
    timer = [NSTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(increaseP) userInfo:nil repeats:YES];
    

    Than have a method called increasePlike this:

    - (void)increaseP
    {
        if (p < maxPValue) {
            // Increase p here and redraw your things
        }
        else {
            [timer invalidate];
        }
    }
    

    Let me know if you have any question and if this works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a recursion function that parses an object/array with a global variable. If
I have a javascript function (function1) that checks some global variables (can the user
If i have global variable in A.dll, that depends on global variable in B.dll
I have a global variable that is an instance of my custom class. How
If I have a global static variable x like in this code #include <stdio.h>
So in jQuery, I have a global variable currentSubNav that stores a current visible
I have a global variable I called Y_VAL which is initialized to a value
Is there any function / global variable in PHP that returns the current state
I have global variable fan_coil_ai_bi, and I use that variable to store some data
So if I have a recursive function with a global variable var_: int var_;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.