如何为我的 UIScrollView 提供图案背景,但顶部不同?
对于我的应用程序的文本编辑部分,我将线条放入 UIScrollView 中以模拟横线信纸。每当 UITextView 滚动时,我的 UIScrollView 就会滚动,以便文本保持固定在行上。
我可以很容易地创建“横格纸”,如下所示:
UIColor *backgroundPattern = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Notepaper-Line"]];
self.noteBackgroundView = scrollView; [scrollView release];
self.noteBackgroundView.backgroundColor = backgroundPattern;
问题是,我希望“信纸”的最上面一行与其他行不同。
浏览Apple的文档,似乎在OS X中,我可以使用NSDrawThreePartImage
来实现这一点,这将允许我制作一个顶部和底部具有固定图像的背景,以及一个平铺图像中间。我有办法在 iPhone 上执行此操作吗?因为它会滚动,所以我认为我不能通过放置另一个 UIImageView 来捏造它。
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, 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将另一个具有顶部图案背景的 UIView 放在 UIScrollView 上但位于 UITextView 下方,以便它覆盖您的信纸图案,大小与顶部图案相同,位置与文本视图完全相同。就像滚动视图和文本视图之间的一层。
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.