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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:35:55+00:00 2026-05-27T20:35:55+00:00

I am making an iPhone game where I have the user selecting what color

  • 0

I am making an iPhone game where I have the user selecting what color they want their car to be in the game. To show which cars can be selected I have UIButtons with background images that are the various cars. To show which car is currently selected I have a button behind the current car color that has a background color of yellow. What I want to happen is that when you click on a car button the yellow button moves behind the button that was clicked. My code looks like:

    -(void)setPlayerCar:(UIButton *)newCar{
    //this code is being called when any of the buttons is clicked
    NSArray *carFiles = [NSArray arrayWithObjects:@"redCar.png",@"blueCar.png",@"greenCar.png",@"purpleCar.png",@"turquioseCar.png",@"yellowCar.png", nil];
    NSString *file = [carFiles objectAtIndex:newCar.tag];
    currentCarImage = file;
    CGRect frame;
    if(currentCarImage == @"redCar.png"){
        frame = CGRectMake(48, 78, 30, 30);
    }
    if(currentCarImage == @"blueCar.png"){
        frame = CGRectMake(83, 78, 30, 30);
    }
    if(currentCarImage == @"greenCar.png"){
        frame = CGRectMake(118, 78, 30, 30);
    }
    if(currentCarImage == @"purpleCar.png"){
        frame = CGRectMake(153, 78, 30, 30);
    }
    if(currentCarImage == @"turquioseCar.png"){
        frame = CGRectMake(188, 78, 30, 30);
    }
    if(currentCarImage == @"yellowCar.png"){
        frame = CGRectMake(223, 78, 30, 30);
    }
    for(UIButton *button in self.pauseScroll.subviews){
        if(button.backgroundColor == [UIColor yellowColor]){
           button.bounds = frame;
        }
        if(button.tag == newCar.tag){
           [self.pauseScroll bringSubviewToFront:button];
        }
    }
}

As far as I know this should move the yellow colored button over to the button that was selected. The problem is this doesn’t happen, when I debug I find that the correct button is being recognized and that frame is being given the right value and that the line: button.bounds = frame; is being executed but when I look at what is being displayed nothing has changed.

  • 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-27T20:35:56+00:00Added an answer on May 27, 2026 at 8:35 pm

    You should be changing the frame of the button and not the bounds. The bounds of a view describe a view’s location and size in its own coordinate space. The frame is the size and location in the superview’s coordinate space.

    if (button.backgroundColor == [UIColor yellowColor]) {
        button.frame = frame;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning on making a game for the iPhone and want to have the
I'm making an iPhone game in which I have two main views, the planning
I'm making an iPhone game and have it so you can chose your difficulty.
I am making a basic platform game for the iPhone and I have encountered
I'm making a game for the iPhone, and I have a class called Robot.
I am making a game for iPhone and want to be able to pause
So I've spent a lot of time making an iPhone game and have recently
I'm making a game on iPhone using cocos2d, and I have a question. In
I'm making an iPhone game in .lua using IntelliJ IDEA, and I have a
Currently I am making a game for iPhone, and want each level to be

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.