UIImageView aspect fit and center

前端 未结 10 1014
执笔经年
执笔经年 2020-12-07 09:48

I have an image view, declared programmatically, and I am setting its image, also programmatically.

However, I find myself unable to set the image to both fit the as

10条回答
  •  没有蜡笔的小新
    2020-12-07 10:17

    Swift

    yourImageView.contentMode = .center
    

    You can use the following options to position your image:

    • scaleToFill
    • scaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent
    • redraw // redraw on bounds change (calls -setNeedsDisplay)
    • center // contents remain same size. positioned adjusted.
    • top
    • bottom
    • left
    • right
    • topLeft
    • topRight
    • bottomLeft
    • bottomRight

提交回复
热议问题