How to set subviews with AutoLayout in UIScrollView programmatically?

前端 未结 4 2122
忘掉有多难
忘掉有多难 2020-12-29 10:17

I am creating app with UiScrollview and UIPagectontrol using Autolayout Programmatically, for

I have Created TKScroller as subclass of UIView, I am init it

4条回答
  •  情话喂你
    2020-12-29 11:07

    If you want your TKScroller fixed to the center and support orientation changes, you can simply put the following code in your init

    self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    

    and you may need to check all your subview's of TKScroller. If you don't like autosize , you can set (one of the three)

    self.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
    self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
    

提交回复
热议问题