Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Background Image is repeated in iPad?

I've got an image with 1x , 2x and 3x types with resolutions 404*750 , 808*1500 and 1212*2250 respectively.

Here is my code:

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

On my iPhone the background is not repeated and its good. but the iPad background is repeated 4 times.

Would you know why is this happening?

like image 786
SUDHAKAR RAYAPUDI Avatar asked Mar 15 '23 23:03

SUDHAKAR RAYAPUDI


1 Answers

From Apple's reference

You can use pattern colors to set the fill or stroke color just as you would a solid color. During drawing, the image in the pattern color is tiled as necessary to cover the given area.

So in iphone device image is large enough to cover the area ... but in ipad it's not large enough to cover the area ... so it will repeat itself.

You can use image.xcassets for different image for iphone and iPad ...

see the screen shot

enter image description here

You can use different image for iPad with proper size to overcome this error

like image 185
Mihir Mehta Avatar answered Mar 27 '23 15:03

Mihir Mehta