Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryotapoi/264ce08f2912e0a3953ca74dc4ce43a3 to your computer and use it in GitHub Desktop.
Save ryotapoi/264ce08f2912e0a3953ca74dc4ce43a3 to your computer and use it in GitHub Desktop.
button.imageView?.contentMode = .scaleAspectFit
button.contentHorizontalAlignment = .fill
button.contentVerticalAlignment = .fill

コードを書くと実行時にAspect Fitになる。 Interface Builder上では正しく表示されない。

IBDesignableで指定できるボタンを作ると便利かも?

contentHorizontalAlignmentcontentVerticalAlignmentUIControl の機能らしいけど、これ UIButton 以外だとどんな動きをするのだろう🧐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment