Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conveniences to size an image view preserving its image's aspect ratio #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NickEntin
Copy link
Collaborator

@NickEntin NickEntin commented Aug 30, 2024

Resolves #135

@NickEntin NickEntin requested a review from dfed August 30, 2024 22:44
Copy link
Collaborator

@dfed dfed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that'll save me some typing!

/// Returns the largest size that will fit within the specified available `width` and `height`, preserving the receiver's `image`'s aspect ratio.
///
/// If `allowUpscaling` is true, the returned size will be at most the image's native size. This is most commonly used when the `image` is a raster image and is not meant to be scaled up.
public func sizeThatFitsPreservingAspectRatio(width: CGFloat, height: CGFloat = .greatestFiniteMagnitude, allowingUpscaling: Bool) -> CGSize {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this technically maxWidth and maxHeight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support sizing image views with aspect ratio preservation
2 participants