-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
enhancementRequest for a new feature or improvement to an existing featureRequest for a new feature or improvement to an existing feature
Description
It's very common to size image views preserving their image's aspect ratio. We currently support this with the AspectRatio
utility, but its call semantics are a bit awkward for this use case. In a simplified example, we end up with something like this:
imageView.bounds.size = imageView.image?.size.aspectRatio.size(toFit: bounds, in: self) ?? .zero
We should add methods calculate the sizeThatFits and to sizeToFit an image view. Additionally these should specify whether upscaling is allowed, since in many cases (e.g. when using a raster image) you want to cap the image at its native size.
func sizeThatFitsPreservingAspectRatio(_ sizeToFit: CGSize, allowingUpscaling: Bool) -> CGSize
func sizeToFitPreservingAspectRatio(_ sizeToFit: CGSize, allowingUpscaling: Bool)
Metadata
Metadata
Assignees
Labels
enhancementRequest for a new feature or improvement to an existing featureRequest for a new feature or improvement to an existing feature