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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:24:42+00:00 2026-05-23T13:24:42+00:00

why is the image I’m trying to render in a custom UIView not being

  • 0

why is the image I’m trying to render in a custom UIView not being fit into window area to scale?

The code below is from a custom class that inherits from UIView. This view has been placed onto the main view in an XIB file, such that it’s not taking up the whole screen.

Also note I tried using both “self.window.frame” as well as “self.frame” as I wasn’t such which one to use. They both given different renderings however neither is one where the image is scaled correct.

Also I’m really after the “Scale To Fit” type of scaling, however I’m not sure how you would get this mode when using a “drawInRect” either?

- (void)drawRect:(CGRect)rect
{
    // Drawing code
    UIImage *altimeterImage = [UIImage imageNamed:@"Atimeter4.png"];
    [altimeterImage drawInRect:self.window.frame];
}

Neither did the following work too:

- (void)drawRect:(CGRect)rect
{
    // Drawing code
    UIImage *altimeterImage = [UIImage imageNamed:@"Atimeter4.png"];
    [altimeterImage drawInRect:self.frame];
}
  • 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-23T13:24:42+00:00Added an answer on May 23, 2026 at 1:24 pm

    Use the bounds property. It will give you the rect in the view’s coordinate space. frame is the coordinates in its parent’s coordinate space so it will not work.

    - (void)drawRect:(CGRect)rect
    {
        // Drawing code
        UIImage *altimeterImage = [UIImage imageNamed:@"Atimeter4.png"];
        [altimeterImage drawInRect:self.bounds];
    }
    

    Normally you would expect rect parameter passed to drawRect: method to be equivalent to the bounds property but it always won’t be so it would be incorrect to rely on it.

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

Sidebar

Related Questions

An image is not shown in Firefox using JavaScript. This is the code, <script
image.html - <img src=showImage.php?id=44/> <-- this is the code I'm trying to make work.
Image a Button on your windows form that does something when being clicked. The
My image is too large for the turtle window. I had to enlarge the
My image is passed into my program from a server and saved as a
Image I have this XML: <ipb> <profile> <id>335389</id> <name>stapia.gutierrez</name> <rating>0</rating> </profile> </ipb> I'm trying
Image the following situation: You're on Windows XP (even though the dialog shown below
Image I have an element like this <someElement a= b= number=1 scale=meters><child/></someElement> scale and
Image below displays the result for: div.test { background: #00F; font-size: 50px; line-height: 50px;
Current image looks like <img src=images/example.jpg /> Now if img src do not have

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.