我在 NSScrollView 中嵌入了 IKImageBrowserView。
我正在尝试实现滚动条,就像我们在 Lion 或 Sparrow 和 Reeder 等其他应用程序中看到的那样。我希望我的滚动条能够覆盖内容。
因此,我遇到的唯一问题是内容超出了滚动条而不是滚动条。
我知道我可以使用 NSScrollView 的 -tile
方法来排列不同的部分,但我不知道如何使用它来达到我的目的。
编辑:这是我的-tile
中的代码:
- (void)tile
{
[super tile];
// We move the scroll to be just below the scrollView
NSScroller *verticalScroller = [self verticalScroller];
NSRect verticalScrollerFrame = [verticalScroller frame];
verticalScrollerFrame.origin.x -= 117.0;
[verticalScroller setFrame:verticalScrollerFrame];
// We expand the scrollview to embrace the whole window
NSRect scrollViewFrame = [self frame];
scrollViewFrame.size.width = 655.0;
[self setFrame:scrollViewFrame];
}
它看起来像这样:
有谁知道为什么滚动条的内容位于内容视图下方?或者有例子吗?
我已经看过这个主题: Overlay NSScroller over content 以及很多其他主题,但没有找到一个答案。
感谢您的帮助!
I have a IKImageBrowserView embedded inside an NSScrollView.
I'm trying achieve scroll bars like those we can see in Lion or other apps like Sparrow and Reeder. I would like my scroll bars to go over the content.
So fare the only problem I have is that the content goes over the scroll bar instead of going under.
I know that I can play with the -tile
methode of the NSScrollView to arrange the different pieces but I don't know how I can use it to my purpose.
EDIT : This is the code in my -tile
:
- (void)tile
{
[super tile];
// We move the scroll to be just below the scrollView
NSScroller *verticalScroller = [self verticalScroller];
NSRect verticalScrollerFrame = [verticalScroller frame];
verticalScrollerFrame.origin.x -= 117.0;
[verticalScroller setFrame:verticalScrollerFrame];
// We expand the scrollview to embrace the whole window
NSRect scrollViewFrame = [self frame];
scrollViewFrame.size.width = 655.0;
[self setFrame:scrollViewFrame];
}
Here is what it looks like:
Does anyone know why the content the scroll bars go under the content view? Or have an example?
I've already looked at this topic : Overlay NSScroller over content and a lot of others without finding an answer.
Thanks for your help!
发布评论
评论(2)
好吧,我想我找到了问题。
在此块中,我使用
[self frame]
来获取NSClipView contentFrame而不是[[self contentView]frame]
。它应该看起来像这样。
我还没有尝试过,但我很确定这就是问题所在。
Ok I think I found the problem.
In this block I'm using
[self frame]
to get the NSClipView contentFrame instead of[[self contentView] frame]
.It should look like this.
I havn't tried it yet but I pretty sure this is the problem.
Sparrow 开发者在这里发布了他的代码:
http://dinhviethoa.tumblr.com/post/6138273608/ios -style-scrollbars-for-nsscrollview
Sparrow developer posted his code here:
http://dinhviethoa.tumblr.com/post/6138273608/ios-style-scrollbars-for-nsscrollview