What type of contents UIViewContentMode mode refers to?

前端 未结 2 1985
傲寒
傲寒 2021-01-05 02:15

According to the official doc on UIView about the contentMode property:

The content mode specifies how the cached bitmap of the view’s layer is          


        
2条回答
  •  自闭症患者
    2021-01-05 02:21

    From the documentation:

    The content mode specifies how the cached bitmap of the view’s layer is adjusted when the view’s bounds change.

    For an image view, this is talking about the image. For a view that draws its content, this is talking about the drawn content. It does not affect the layout of subviews.

    You need to look at the autoresizing masks in place on the subviews. Content mode is a red herring here. If you can't achieve the layout you need using autoresizing masks, then you need to implement layoutSubviews and calculate the subview positions and frames manually.

    from jrturton's answer to: https://stackoverflow.com/a/14111480/1374512

提交回复
热议问题