How to center a subview of UIView

前端 未结 14 1963
無奈伤痛
無奈伤痛 2020-11-30 16:47

I have a UIView inside a UIViewm and I want the inner UIView to be always centered inside the outer one, without it having to resize t

14条回答
  •  难免孤独
    2020-11-30 17:28

    Using the same center in the view and subview is the simplest way of doing it. You can do something like this,

    UIView *innerView = ....;
    innerView.view.center = self.view.center;
    [self.view addSubView:innerView];
    

提交回复
热议问题