imneo
OP
Created
Mar ’24
Replies
4
Boosts
0
Views
996
Participants
3
You can call the units "points", but they do not necessarily have anything to do with printer's points. To see how they correspond to hardware pixels, you look at the "backing" coordinate system, with methods such as convertPointToBacking:
.
Unit is in points (to be independent of screen resolution)
To convert, you use UIScreen.main.scale, which is presently 1, 2 or 3 depending on screen resolution.
See details here: https://gist.github.com/jeffaburt/68fdee211b9f9061fbffc28819b5e540
Maybe my question is too general.
I have a need to calculate all width of an NSTableView. However, I found that total width of all columns is far less than NSTableView.bound.width:
let width = tableView.tableColumns.reduce(0) { ac, col in ac + col.width }
print(width, tableView.bounds.width)
This is true even I manually adjust last column so that it fills the gap between the column and tableview right border.
-----------| <- table right border
last column|
-----------|
So I assume NSTableColumn.width and NSView.bounds.width are using different units.
Have you considered that there may be space between columns? See the intercellSpacing
property.