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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:11:06+00:00 2026-05-16T10:11:06+00:00

I have a custom UIButton with a png inside it. I have quite a

  • 0

I have a custom UIButton with a png inside it. I have quite a few of them in my app and everywhere they seem to be working fine.

In one location they are inside a UIView that is a headerView for a UITableview.

Whenever I press on them, only on iPhone 2G the image box goes black while the rest of the UIButton (it’s got a title…) looks fine. After you go out of the view controller and come back the “pressed” image shows fine.

Any ideas why? My images are compressed inside the app file.

Thanks!

UPDATE #1:
I used some code that someone graciously offered here on stackoverflow that generates an image from a backcolor so you could put it to use via backgroundImage property. I use it and that seems to be causing the problem. Everytime I press my button it takes my image used and renders a black box instead of it while it displayed the image generated correctly.

- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;

}

  • 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-16T10:11:07+00:00Added an answer on May 16, 2026 at 10:11 am

    Solved!

    This line of code seems to cause a problem for iOS 3.1.3 (I assume all 3.1).

    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    

    Once you make the pattern image bigger by atleast 1 pixel you are all good. For example:

    CGRect rect = CGRectMake(0.0f, 0.0f, 5.0f, 5.0f);
    

    Solves the problem.

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

Sidebar

Related Questions

In my iPad App, I have one custom class inherited from UIButton. I am
In my iOS 5 app I have a custom UIButton that has a red
I have a very simply subclass of UIButton that will fire off a custom
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom UITableViewCell s as well as headers and footers. Each of them
I have a custom UIButton in my viewcontroller that should have either the image
I have a custom class, and that class has a UIButton instance variable. I
I have custom annotation pin at app: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
I have created a custom UIButton (UIButton subclass) for my application. Within this button's

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.