开发者

How can I I give my UIScrollView a pattern background, but with a different top?

For the text-editing part of my app, I am putting lines in a UIScrollView to simulate lined notepaper. My UIScrollView will scroll whenever the UITextView scrolls, so that the text stays fixed to the lines.

I can create 'lined paper' quite easily like so:

UIColor *backgroundPattern = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Notepaper-Line"]];
self.noteBackgroundView = scrollView; [scrollView release];
self.noteBackgroundView.backgroundColor = backgroundPattern;

The problem is, I would like the very top line of my 'notepaper' to be different from the rest.

Looking through Apple's documentation, it seems that, in OS X, I can achieve this using NSDrawThreePartImage, which would allow me to make a background with fixed images for the top and bottom开发者_StackOverflow, and a tiled image in the middle. Is there a way for me to do this on the iPhone? Since it's going to scroll, I don't think I can just fudge it by placing another UIImageView.


You can put another UIView with top pattern background on to of the UIScrollView but below UITextView, so that it covers your notepaper pattern, sized like the top pattern and positioned exactly like the text view. Like a layer in between the scroll view and text view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜