SimplyKiwi
SimplyKiwi

Reputation: 12444

Repeating background image for UITextView?

Currently I am doing this to have a background image for my UITextView:

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, textView.frame.size.width, textView.frame.size.height)];
imgView.image = [UIImage imageNamed:@"background.png"];
[textView addSubview: imgView];
[textView sendSubviewToBack: imgView];   
[imgView release];

But the problem is, it does not repeat. What I want, is the image to repeat after each UIImage.

Is this possible?

Thanks!

Upvotes: 1

Views: 3137

Answers (1)

QED
QED

Reputation: 9913

textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed@"background"]];

Yes, omit the .png from the image name, it will allow you to provide a Retina version [email protected].

Upvotes: 11

Related Questions