如何集中UIView的子视图 [英] How to center a subview of UIView
本文介绍了如何集中UIView的子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 UIView
m中有一个 UIView
,我想要内部 UIView
总是在外部的中心内,而不必调整宽度和高度。
I have a UIView
inside a UIView
m and I want the inner UIView
to be always centered inside the outer one, without it having to resize the width and height.
我设置了支柱和弹簧,以便它位于上/左/右/下,没有设置调整大小。但它仍然没有中心。有什么想法?
I've set the struts and springs so that it's on top/left/right/bottom without setting the resize. But it still doesn't center. Any idea?
推荐答案
尝试:
yourSubView.center = CGPointMake(yourView.frame.size.width / 2,
yourView.frame.size.height / 2);
这篇关于如何集中UIView的子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文