0

I tried to fill a UIView with tiled background images.

The size of the UIView is 1136 * 640, and the size of the background image I use is 64 * 64.

The code I write is:

self.view.backgroundColor = [UIColor colorWithPatternImage:
                                [UIImage imageNamed:@"paper_texture.png"]]; 

But after I set the background image for this view, there are lines that separate each tiled background image.

I tested this using css repeating background image in html, and there are no such lines.

Spencer Feng
  • 25
  • 2
  • 6
  • http://stackoverflow.com/questions/7624723/colorwithpatternimage-creates-black-grids-in-iphone-4 a couple possible solutions there – Chris Tetreault Aug 15 '13 at 12:43
  • Have you verified that the image itself doesn't have a border? Have you extra double verified it? Can you show us the image? – rob mayoff Aug 16 '13 at 07:15

2 Answers2

0

Do you have a Retina-resolution @2x version of your image? If so, remove the .png from the image name and iOS will load the correct version. If you are loading the wrong image, perhaps loading the correct one will get rid of the lines.

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
  • I have a Retina-resolution image. I removed the .png from the image name, but the separating lines are still there :( – Spencer Feng Aug 16 '13 at 00:46
0

I finally solved this problem:

  1. Open this image in Photoshop

  2. Select all and copy it to clipboard

  3. Create a new file in Photoshop. Set this new file as follows: a. The same dimension as the image b. RGB and 8bit depth with 72 pixels/inch c. White background

  4. Paste the image I copied in step 2 to this new file.

  5. Save this file and use the new image

Spencer Feng
  • 25
  • 2
  • 6