UIView background sizing issue

后端 未结 7 733
梦如初夏
梦如初夏 2021-01-28 07:06

I\'m adding a UIImageView to the UIViewController\'s UIView as I would normally, with the frame of the image view being the same as self.view to make sure that the

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-28 07:36

    See your self.view, it is 20 points below, as the status bar is shown. hence, the self.view.frame is (0,20,w,h)

    your image view takes the same rect (0,20,w,h) and adds it to self.view. With respect to self.view the image view sets its frame to 20 points below the "y" position of self.view.

    Try setting self.view.bounds to the image view frame.

    Hope this helps!

提交回复
热议问题