Skip to content

Commit e18ce0f

Browse files
committed
NSControl, NSImageView support for sizeThatFits
1 parent 9c15fc0 commit e18ce0f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/UIKit/NSView+LX.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ extension NSView: Layoutable {
4545
}
4646

4747
public func lx_sizeThatFits(_ size: CGSize) -> CGSize {
48+
49+
if let control = self as? NSControl {
50+
return control.sizeThatFits(size)
51+
}
52+
else if let imageView = self as? NSImageView {
53+
return imageView.image?.size ?? CGSize()
54+
}
55+
4856
return CGSize()
4957
}
5058
}

0 commit comments

Comments
 (0)