简体   繁体   中英

NSView - draw on top

Working on a music player. I have an NSTableView with a bunch of NSTableCellViews, which each have an NSSlider that unhides when that track starts playing.

Now the problem is, we want the slider to draw right at the bottom of the NSTableCellView, but that means that the knobRect overlaps with the NSTableCellView below it. What is the best way to make sure the knob draws on top of the other table cell views?

图片重叠

Adjusting row heights is going to be the easiest thing. (especially if you only allow one playback at a time :))

You could try the setFloatsGroupRows: method of NSTableView and NSTableViewDelegate method tableView:isGroupRow: This combo gives some very unique built in customizations, but from the looks of it, you've already customized a fair amount so you should be capable.

Also you could try what they wrap which is actually NSScrollView's addFloatingSubview:forAxis: However, that said, NSTableView and the hierarchy it lives in are pretty tightly wound together so you may find this behaves very oddly with NSTableView when you're not doing the floating group row thing.

In the end, you might want to just revisit your UI design. Maybe your scroller could be like this where the edge of a color ramp is your slider so you can fit it right on top of the playing track : 示例滑块

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM