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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:07:50+00:00 2026-06-05T09:07:50+00:00

I use 20 UIButtons in my application .i set the background image of all

  • 0

I use 20 UIButtons in my application .i set the background image of all these UIButtons on click event.all these UIButton are save in NSMutableArray.here is code.

             saveBtn = [[NSMutableArray alloc] init];
             for (int i=0; i<20; i++) {
             UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
             btn.frame = CGRectMake(spacex, spacey, 30.0, 30.0);
             idx = arc4random()%[arr count];
             NSString* titre1 = [arr objectAtIndex:idx];
             [btn setTitle:titre1 forState:UIControlStateNormal];   
             spacex = spacex + 30;
             [saveBtn addObject:btn];
             [self.view addSubview:btn];
          }

i don it successful here is my code.

 UIButton *currentButton = (UIButton *)sender;
 UIImage * imgNormal = [UIImage imageNamed:@"subtabButton.png"];
 [currentButton setBackgroundImage:imgNormal forState:UIControlStateNormal];
 [currentButton setTitle:currentButton.titleLabel.text forState:UIControlStateNormal];

But between these 20 UIButtons there are 3 UIButtons ,i want that when player click one of these three UIButtons,all the previous set background images are remove from UIButtons.can any one guide me how we can do it..thanx in advance.

  • 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-05T09:07:53+00:00Added an answer on June 5, 2026 at 9:07 am
    for (UIButton *btn in yourArrayOfButtons)
    {
       [btn setBackgroundImage:[UIImage imageNamed:@"nameofmyimage"] forState:UIControlStateNormal];
    }
    

    or if you want to remove the image:

    for (UIButton *btn in yourArrayOfButtons)
    {
       [btn setBackgroundImage:nil forState:UIControlStateNormal];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the this code in my iPhone application: UIButton * MyButton=[UIButton ButtonWithType:UIButtonTypeRoundRect]retain];
I use this code. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for
Here is my code AppDelegate.m I use this code to start AVAudioPlayer. It works
I have several UIButtons created from an NSMutableArray. I'm trying to customize each UIButton
I want to use Custom UIButton instead of BarButton in Master-Detail Application template. Please
Ok, here’s my problem. I have a rather large set of UIButtons that have
I have multiple UIButtons in my app. I also use interfacebuilder. In my .h
Kind of following this tutorial here: http://mobile.tutsplus.com/tutorials/iphone/iphone-core-data/ I use the fetch records method in
Is it possible to use UIButtons with my own true type font? I found
I use a UIView animation to randomly animate 5 squares (UIButtons) around the screen.

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.