使 NSScroller 变大
我正在制作一个针对外部触摸屏进行优化的 Cocoa 应用程序,所以我想在 NSScrollView 中制作一个大的滚动条。我尝试过调整滚动条框架的大小,但是绘图和鼠标事件都只发生在滚动区域中,它不会变宽(它是垂直滚动条)。这是我正在使用的代码(来自子类 NSScrollView):
- (void)tile{
[super tile];
NSScroller *vertScroll = [self verticalScroller];
NSRect vertScrollFrame = [vertScroll frame];
NSView *content = [self contentView];
NSRect contentFrame = [content frame];
contentFrame.size.width -= 50;
vertScrollFrame.origin.x -= 50;
vertScrollFrame.size.width += 50;
[vertScroll setFrame:vertScrollFrame];
[content setFrame:contentFrame];
}
我尝试对 NSScroller 进行子类化,但我不知道如何扩展它。
I'm making a Cocoa application optimized for external touch sensitive screens, so I want to make a large scollbar in an NSScrollView. I've tried just to resize the scrollers frame, but both drawing and mouse events only happens in the scroll area, it doesn't get wider (it's the vertical scroller). This is the code I'm using (from the subclassed NSScrollView):
- (void)tile{
[super tile];
NSScroller *vertScroll = [self verticalScroller];
NSRect vertScrollFrame = [vertScroll frame];
NSView *content = [self contentView];
NSRect contentFrame = [content frame];
contentFrame.size.width -= 50;
vertScrollFrame.origin.x -= 50;
vertScrollFrame.size.width += 50;
[vertScroll setFrame:vertScrollFrame];
[content setFrame:contentFrame];
}
I've tried to subclass the NSScroller, but I don't know how I would extent it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的自定义滚动视图是否存在于 nib/xib 中?如果是这样,您是否在 Interface Builder 中将滚动视图的类标识设置为自定义类的名称?它位于检查器窗口的“身份”选项卡中。
Does your customized scroll view exist in a nib/xib? If so, have you set the scroll view's class identity in Interface Builder to the name of your custom class? It's found in the "Identity" tab of the Inspector window.