I’m trying to add a back ground image to UITextView. The image is just a small border which will be placed at the top of text view. (the image resembles teared paper image). I’m using following code
UIImageView *imgView = [[UIImageView alloc]initWithFrame: CGRectMake(0, 0, 320, 13)];
imgView.image = [UIImage imageNamed: @"teared_paper.png"];
[tView addSubview: imgView];
[tView sendSubviewToBack: imgView];
[imgView release];
My text view’s height is 150 pixels only. (text view occupies only small portion of view and it is at the top of the view so that it will appear to the user when keyboard is there)
The problem is that, when I add more lines of text, text view is scrolling automatically. And at the same time, the background image that I added is also scrolling. How can I prevent the background image to stay on the top all the time irrespective of scrolling.
Don’t add the image view as a subview of the text view. Instead, have both the image view and the text view as children of the main view, position the image view behind the text view, and set the background color of the text view to transparent with: