macOS Objective-C:代码创建的NSScrollView出现异常滚动条元素求助
移除NSScrollView滚动条上方的未知方形元素(macOS Objective-C)
我在macOS平台使用Objective-C开发(非Swift、非iOS),通过代码创建了嵌套NSTableView的NSScrollView,现在滚动条上方出现一个方形元素,该元素在视图层级调试器中无法显示,希望将其移除。
问题演示

视图层级截图

相关代码
// Create tableView NSTableView* tableView = [[NSTableView alloc] initWithFrame:NSZeroRect]; tableView.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone; tableView.translatesAutoresizingMaskIntoConstraints = NO; tableView.backgroundColor = [NSColor clearColor]; tableView.delegate = self.delegate ? self.delegate : weakSelf; tableView.dataSource = self.delegate ? self.delegate : weakSelf; tableView.rowHeight = height; // predefined tableView.intercellSpacing = NSMakeSize(2, 2); tableView.headerView = [[NSTableHeaderView alloc] initWithFrame:NSMakeRect(0, 0, 0, CGFLOAT_MIN)]; tableView.columnAutoresizingStyle = NSTableViewUniformColumnAutoresizingStyle; if (@available(macOS 11.0, *)) {tableView.style = NSTableViewStylePlain;} self.tableView = tableView; // Create Scroll View NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect]; scrollView.verticalScrollElasticity = NSScrollElasticityAutomatic; // Setup scrollView scrollView.drawsBackground = NO; scrollView.hasVerticalScroller = YES; scrollView.hasHorizontalScroller = YES; scrollView.autohidesScrollers = YES; scrollView.translatesAutoresizingMaskIntoConstraints = NO; scrollView.documentView = tableView; scrollView.scrollerStyle = NSScrollerStyleLegacy; // Must be legacy (!) scrollView.automaticallyAdjustsContentInsets = NO; scrollView.contentInsets = insets; scrollView.scrollerInsets = NSEdgeInsetsMake(-(insets.top), -(insets.left), -(insets.bottom), -(insets.right)); // insets are predefined self.scrollView = scrollView; [self.view addSubview:scrollView];
内容的提问来源于stack exchange,提问作者Pat_Morita
相关产品推荐
相关产品推荐

