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
3 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
2
//
3
3
// SPDX-License-Identifier: MIT
4
4
5
5
+
import AVFoundation
5
6
import AppKit
6
7
7
8
open class AquaSegmentedCell: NSSegmentedCell {
···
146
147
if let image = image(forSegment: segment) {
147
148
let inset = frame.width * 0.25
148
149
let imageRect = frame.insetBy(dx: inset, dy: inset)
149
149
-
image.draw(in: imageRect)
150
150
+
let fittedRect = AVMakeRect(
151
151
+
aspectRatio: image.size,
152
152
+
insideRect: imageRect
153
153
+
)
154
154
+
image.draw(in: fittedRect)
150
155
}
151
156
}
152
157