Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save stephen-francis/b5b4a63dacafed12256108615ad81306 to your computer and use it in GitHub Desktop.

Select an option

Save stephen-francis/b5b4a63dacafed12256108615ad81306 to your computer and use it in GitHub Desktop.
adjustsImageSizeForAccessibilityContentSizeCategory
extension UIImageView {
static func scaledImageWithName(_ name: String, sizeValue: CGFloat) -> UIImageView {
let widthAndHeight = UIFontMetrics.default.scaledValue(for: sizeValue)
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: widthAndHeight, height: widthAndHeight))
imageView.image = UIImage(named: name)
return imageView
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment