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

  • SEARCH
  • Home
  • 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 744243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:57:21+00:00 2026-05-14T08:57:21+00:00

I didn’t use subviews but painted my things with -drawRect: inside an UIView subclass.

  • 0

I didn’t use subviews but painted my things with -drawRect: inside an UIView subclass. Now I want to do some animations in there.

I guess that I can’t count on core animation now since I have no subviews. So how would I animate then? Would I set up a timer which fires like 30 times per second? How would I know the animation step? Would I make an ivar which counts the frame of the animation so that I can do my stuff in -drawRect as it gets called?

  • 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-14T08:57:21+00:00Added an answer on May 14, 2026 at 8:57 am

    You can do exactly that: have an instance variable with the frame number and increment it in the timer. If you don’t care about easing, you can then just multiply the frame number by a speed and then set that to the property which you want to animate.

    -(void)timerfunction{
        ++frame;
        [self setNeedsDisplay];
    }
    
    -(void)drawRect:(CGRect)rect{
        CGContextFillRect(UIGraphicsGetCurrentContext(),CGRectMake((2*frame)+5,5,20,20));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't attend PDC 2008, but I heard some news that C# 4.0 is
I didn't do C# for quite some time, but I'm updating some of my
I didn't upgrade to Vista until May or so and one of the things
I want use html5's new tag to play a wav file (currently only supported
(Didn't mean to create a new question, but revised the old one enough that
Sorry i really didn't know how to phrase the question any better but here
(please excuse that I didn't use aliases). I would like my query output to
Didn't Snow Leopard introduce some alternative to the old beginSheet: method that allows using
I didn't notice it until today during some testing locally on my pc, that
I didn't get the answer to this anywhere. What is the runtime complexity of

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.