A collection of user interface components and drawing routines for building tasteful apps using AppKit.
appkit swift aqua ui mac

segmented cell: aspect fit for image

+6 -1
+6 -1
Sources/AquaKit/Controls and Views/AquaSegmentedCell.swift
··· 2 2 // 3 3 // SPDX-License-Identifier: MIT 4 4 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 - image.draw(in: imageRect) 150 + let fittedRect = AVMakeRect( 151 + aspectRatio: image.size, 152 + insideRect: imageRect 153 + ) 154 + image.draw(in: fittedRect) 150 155 } 151 156 } 152 157