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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:57:12+00:00 2026-05-25T01:57:12+00:00

I am subclassing UIView, retrieving a remote image then drawing it to the view

  • 0

I am subclassing UIView, retrieving a remote image then drawing it to the view using drawRect. This works fine, but the image is then skewed based upon what I set for my views frame.

I can add a contentMode of UIViewContentModeScaleAspectFill to my UIView but it doesn’t seem to apply at all to my UIImage that I am drawing, it still squishes the UIImage because it follows the views frame size.

It seems like I should do something like the following, but that just zooms the image 100% within my frame rather than following the contentMode setting:

[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];

Do I need to do something specific in drawRect: to make my image follow the contentMode property?

  • 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-25T01:57:13+00:00Added an answer on May 25, 2026 at 1:57 am

    I think the simplest solution would be to subclass UIImageView instead of UIView and use the class’s contentMode property. Then you don’t need to call drawRect, just load the image into the imageView.

    Alternately, if you need to subclass UIView, add a UIImageView to your view, setup springs and struts, set the contentMode, and load up your image.

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

Sidebar

Related Questions

I'm subclassing UIView to make a custom view by overriding drawRect:. I need to
I'm subclassing UIView using the standard EAGLView framework. When I detect orientation changes, I
I am currently subclassing UIView to create custom objects, they work perfectly fine In
I'm subclassing NSUserDefaults in my application. A side effect of this is I can't
I'm subclassing UITableViewCell and adding two subviews (image, UILabel). When the row is touched.
I am subclassing a UITableViewCell and in the drawRect: method I want to draw
After a quick subclassing of Windows.Forms.Label and then noticing that the default Label is
I'm subclassing a WTL combobox and I'm owner-drawing the items of the combobox. The
I'm subclassing JTable and using a DefaultTableModel to model my table data. The following
I'm writing a small painting app for iOS. I'm subclassing a UIView ad performing

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.