Objective-C –在视图内定位视图
有没有办法向视图添加一些子视图,然后能够定位该视图,以便所有子视图都将“跟随”。可以说,充当子视图的容器,因此我只需要重新定位视图,而不必重新定位该视图中的所有子视图。
我正在寻找一种解决方案来以编程方式执行此操作,而不是在 IB 中。
Is there a way to add some subviews to a view and then be able to position that view so all the subviews will "follow". Acting as a container so to speak for the subviews so I only need to reposition the view and not having to reposition all the subviews in that view.
I'm looking for a solution to do this programtically, not in IB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 UIView 作为父视图,则所有子视图都会跟随。
现在当你设置parentView的新框架时。 btn1 将具有相对于parentView 的位置。
我希望我正确理解你的问题。
编辑:
添加评论
If you use a
UIView
as a parent view all subviews will follow.Now when you set the new frame of the parentView. The btn1 will have it's position relative to the parentView.
I Hope I understood your question correctly.
EDIT:
Added comments