我想更改其颜色,但是我不确定是否可以继承NSScrollView或NSClipView。或者是否可以将角插入为常规NSView。
我不需要代码。只是有关如何操作的提示。
最佳答案
mekentosj已answered elsewhere on stackoverflow。要子类化的类是NSScrollView。
@interface MyScrollView : NSScrollView {
}
@end
@implementation MyScrollView
- (void)drawRect:(NSRect)rect{
[super drawRect: rect];
if([self hasVerticalScroller] && [self hasHorizontalScroller]){
NSRect vframe = [[self verticalScroller]frame];
NSRect hframe = [[self horizontalScroller]frame];
NSRect corner;
corner.origin.x = NSMaxX(hframe);
corner.origin.y = NSMinY(hframe);
corner.size.width = NSWidth(vframe);
corner.size.height = NSHeight(hframe);
// your custom drawing in the corner rect here
[[NSColor redColor] set];
NSRectFill(corner);
}
}
@end
关于cocoa - 如何填充NSScrollView的右下角?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3413292/