Easiest solution is -
NSInteger distanceBetweenLines = 50; // Distance between each line
NSInteger startMargin = 20; // For any starting margin for our first line
for (int i = 0; i < numberOfLines; i++) {
UIView *lineView = [[UIView alloc] init];
[lineView setFrame:CGRectMake(0, distanceBetweenLines * i + startMargin,
200, 1)];
[lineView setBackgroundColor:[UIColor blackColor]];
[self addSubview:lineView];
[lineView release];
}
This will create multiple UIView lines over your text view. The alternative and perhaps easier way (albeit less flexible) to do it is:
// linesImage is an image with a white background and black lines
UIImageView *linesImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"linesImage"]];
[linesImageView setFrame:CGRectMake(x, y, width, height)];
[self addSubview:linesImageView];
[linesImageView release];
// Just need to maker sure the textview is added to the view after imageview is created to make sure it is on top... or just bring the textview forward in your subviews stack
textview.backgroundColor = [UIColor clearColor]; // So that lines image can be seen through the text view
Apologies if the code doesn't compile, as I haven't tested it in Xcode.
Cheers,
Raal
Dapp - the app design app