ios: colorWithPatternImage , stretch image full screen

ios, iphone, uicolor

Solution

Have a try.

`self.layer.contents = (id)[UIImage imageNamed:@"freshBackground.png"].CGImage;`

Swift:

self.view.layer.contents = UIImage(named: "freshBackground")!.cgImage

Problem

I have one view , and want set backGroudColor for this view by UIImage. The code as : ``` self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backImage.png"]]; ``` the problem is: the backImage'frame is small than the view. how to stretch UIImage to full my view. I konw use UIImageView can reach. someone have good idea? update: I can't upload one image. Like this:backImge's size is 30*30, and my view's size is 1024*700, when i use `myview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backImage.png"]];` The result is myview's backGroup has many 'backImage.png'. my goal is have one 'backImage.png' streth full myview.

Original source