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 8426339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:30:58+00:00 2026-06-10T04:30:58+00:00

In my iphone application I have several images. lets say some small square images.

  • 0

In my iphone application I have several images. lets say some small square images. what I want is I want that small objects appear from the top of the screen at rondom times and leaves the screen from the bottom. I mean, for example, object randomly appeared from the x:30 y:0 point (x value must be random) and leaves from the x:30 y:460 with an animation.

I am programming an 2d racing game and they are the cars. hope it is clear.

edit: well I tried to change the frame the numbers belong to something else. But I could not have the frame of the image and also I could not figure out how to generate position randomly more than one time. since I was planning to put it on the viewDidLoad.

[UIView beginAnimations:@"myAnimation" context:nil];
CGRect Frame = image.frame;
if(Frame.origin.y == 340){
    Frame.origin.y = 260;
}else{
    Frame.origin.y = 340;
}
image.frame = Frame;
[UIView commitAnimations];
  • 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-06-10T04:30:58+00:00Added an answer on June 10, 2026 at 4:30 am

    Your example code doesn’t show what you are asking for. It’s also really hard to guess what you want.

    Here’s my literal interpretation of what you have asked for

    for (int i = 0; i < 100; i++) {
    
        CGRect startFrame = CGRectMake(arc4random_uniform(320), -50, 50, 50);
        CGRect endFrame   = CGRectMake(arc4random_uniform(320),  
                                       CGRectGetHeight(self.view.bounds) + 50, 
                                       50, 
                                       50);
    
        UIView *animatedView = [[UIView alloc] initWithFrame:startFrame];
        animatedView.backgroundColor = [UIColor redColor];
    
        [self.view addSubview:animatedView];
    
        [UIView animateWithDuration:2.f
                              delay:i * 0.5f
                            options:UIViewAnimationCurveLinear
                         animations:^{
                             animatedView.frame = endFrame;
                         } completion:^(BOOL finished) {
                             [animatedView removeFromSuperview];
                         }];
    }
    

    If you stick this in viewDidAppear: then you’ll see 100 objects animate in the way you want. Obviously this is extremely inefficient and you may want to look at recycling the views etc but this shows how to animate views with UIView animation with some random points

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

Sidebar

Related Questions

So I have an iPhone application that needs to: Post several strings and up
I am building application that required some data from iPhone's Call log(read only). The
I have an iPhone application that contains several views and their associated controllers. Looking
I have an iPhone application which has some methods to gather information from the
Within my iPhone application I have a common tab bar with three tabs that
I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
I'm developing an iPhone application where I have a bunch of images bundled with
So I have an iPhone application running that is controlled at the highest level
I have an iPhone application where i download information from the internet and put
I have a Cocos2D iPhone application that requires a set of CGRects overlaid on

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.