iOS: Add subview with a fix position on screen

后端 未结 4 1602
执念已碎
执念已碎 2021-01-01 04:17

How do I fix a subviews position on screen (especially in UIScrollView and UITableView)? I think in storyboard

[self.view addSubview:aSubView];
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 04:57

    It can be done, by moving sub (your) view from UIScrollView to super view of scrollview.

    Here is simple example:
    Place/set your button over scroll view (not inside scroll view) as shown here in this snapshot. And also set button constraints (position) with respect to super view of your scrollview.

    Here is ref. snapshot of hierarchy of position of each view over each-other.

提交回复
热议问题