tangled
alpha
login
or
join now
jonmsterling.com
/
AquaKit
4
fork
atom
A collection of user interface components and drawing routines for building tasteful apps using AppKit.
appkit
swift
aqua
ui
mac
4
fork
atom
overview
issues
1
pulls
pipelines
segmented cell: aspect fit for image
jonmsterling.com
4 weeks ago
d7dab60d
be4824e7
+6
-1
1 changed file
expand all
collapse all
unified
split
Sources
AquaKit
Controls and Views
AquaSegmentedCell.swift
+6
-1
Sources/AquaKit/Controls and Views/AquaSegmentedCell.swift
···
2
//
3
// SPDX-License-Identifier: MIT
4
0
5
import AppKit
6
7
open class AquaSegmentedCell: NSSegmentedCell {
···
146
if let image = image(forSegment: segment) {
147
let inset = frame.width * 0.25
148
let imageRect = frame.insetBy(dx: inset, dy: inset)
149
-
image.draw(in: imageRect)
0
0
0
0
150
}
151
}
152
···
2
//
3
// SPDX-License-Identifier: MIT
4
5
+
import AVFoundation
6
import AppKit
7
8
open class AquaSegmentedCell: NSSegmentedCell {
···
147
if let image = image(forSegment: segment) {
148
let inset = frame.width * 0.25
149
let imageRect = frame.insetBy(dx: inset, dy: inset)
150
+
let fittedRect = AVMakeRect(
151
+
aspectRatio: image.size,
152
+
insideRect: imageRect
153
+
)
154
+
image.draw(in: fittedRect)
155
}
156
}
157