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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:50:10+00:00 2026-05-15T07:50:10+00:00

I’m setting a view background to a repeating image using colorWithPatternImage. If the view

  • 0

I’m setting a view background to a repeating image using colorWithPatternImage. If the view size changes after I’ve set the background the first time, the image gets stretched instead of repeating for the new size – any ideas how I can fix this?

This is what I’m doing:

  • set the view’s background in viewDidLoad:

    frameView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@”frame-repeat.png”]];

  • grab some information from the server, update the view, change the view’s frame size to fit the new content (usually, this means making the view taller)

  • background image is now stretched, even if I set the backgroundColor again using the exact same code.

If I don’t do the initial background set, and only set it after I retrieve the data from the server and change the view size, it looks great – repeats, and no stretching. However, that means no background while the data is loading… looks ugly.

Has anyone else run into this?

Thanks for any help!

  • 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-15T07:50:11+00:00Added an answer on May 15, 2026 at 7:50 am

    The answer is quite simple, just call:

    [[self view] setNeedsDisplay];
    

    in the controller when you change the frame size (or wherever you do it, bottom line is to send a setNeedsDisplay message to the view after the frame change). If this doesn’t work – try setting the background color.

    And if this doesn’t work, implement your own custom view, and in it override the method:

    - (void) drawRect:(CGRect) rect {
       CGRect myBounds = self.bounds;
       CGContextRef context = UIGraphicsGetCurrentContext();
       [[UIColor colorWithPatternImage:[UIImage imageNamed:@"frame-repeat.png.png"]]set];
       CGContextFillRect(context, myBounds);
    }
    

    And then, after the resizing, send the setNeedsDisplay to your view. This will work for 100%.

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

Sidebar

Ask A Question

Stats

  • Questions 468k
  • Answers 468k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's the obvious, non linq solution: foreach(var person in personList)… May 16, 2026 at 2:17 am
  • Editorial Team
    Editorial Team added an answer Use the ClipToBounds property on the Canvas: <Canvas ClipToBounds="True" HorizontalAlignment="Center"… May 16, 2026 at 2:17 am
  • Editorial Team
    Editorial Team added an answer MIDP 2.0 JSR-118 JavaDoc. All JavaME docs. May 16, 2026 at 2:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.