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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:48:37+00:00 2026-06-13T08:48:37+00:00

I have this UIButton, he has an image, on normal iPhone it works fine,

  • 0

I have this UIButton, he has an image, on normal iPhone it works fine, the image contentMode is set to UIViewcontentModeCenter and its fine. but on retina, the image is not center, it’s big and doesn’t fit into the button frame.

Why is that and how can I fix it?

[theImageView setImage:Image forState:UIControlStateNormal];
[theImageButton setImage:Image forState:UIControlStateHighlighted];
[theImageButton setImage:Image forState:UIControlStateSelected];
[theImageButton setBackgroundColor:[UIColor clearColor]];
[theImageButton addTarget:self action:@selector(dismissKeyboard:) forControlEvents:UIControlEventAllTouchEvents];
theImageButton.imageView.contentMode = UIViewContentModeCenter;

The image loading:

- (UIImage *)loadScreenShotImageFromDocumentsDirectory
{
    UIImage * tempimage;
    NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
    NSString *docDirectory = [sysPaths objectAtIndex:0];
    NSString *filePath = [NSString stringWithFormat:@"%@/MeasureScreenShot.png", docDirectory];
    tempimage = [[UIImage alloc] initWithContentsOfFile:filePath];

    return tempimage;
}

I have to say, that the image that loaded into the contentMode is a screen shot that has been taken programmatically. maybe it has to do with it (anyway on normal display it works fine).

Thanks!

  • 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-13T08:48:37+00:00Added an answer on June 13, 2026 at 8:48 am

    Sounds like you’re getting a retina image, with 1.0 scale. You need to tell the system, that your image is actually 2.0, if you use contexts to capture screenshot, use

    UIGraphicsBeginImageContextWithOptions(..., ..., 0.0);
    

    0.0 tells it to use current device’s main screen scale, or you can specify correct scale yourself.

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

Sidebar

Related Questions

I have a UIButton which has images set for both Normal and Selected State.
I have a UIbutton title that I set with [[buttons objectAtIndex:selectedButtonTag] setTitle:file forState:UIControlStateNormal]; This
Is it possible to have a custom UIButton that has an image covering only
I have a UIButton that has an initial value that I have set in
I have a viewController called MainViewController, which has a UIButton. When tapped, this button
UIButton has a single initializer buttonWithType . But this is a factory method and
I am working on application for Ipad.in this application i have a UIButton on
In IB I have a view with a UIButton of Type Custom, it has
here i have this code that i'm trying where openingHoursView.ohLocation has two values value1
I have UIButton instance called card. I have an object called Representer, which has

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.