Questions tagged «cgrect»


7
获取UIView相对于其超级视图的位置
我有一个UIView,其中安排了UIButtons。我想找到那些UIButton的位置。 我知道这buttons.frame将给我职位,但仅就其直接监督而言,它只会给我职位。 关于UIButtons超级视图的超级视图,有没有办法找到这些按钮的位置? 例如,假设有一个名为“ firstView”的UIView。 然后,我有另一个UIView,“ secondView”。该“ SecondView”是“ firstView”的子视图。 然后,我将UIButton作为“ secondView”的子视图。 ->UIViewController.view --->FirstView A ------->SecondView B ------------>Button 现在,有什么方法可以找到该UIButton相对于“ firstView”的位置?

4
比较两个CGRect
我需要检查我的视图框架是否等于给定的CGRect。我试图这样做: CGRect rect = CGRectMake(20, 20, 20, 20); if (self.view.frame == rect) { // do some stuff } 但是,我说错了Invalid operands to binary expression('CGRect' (aka 'struct CGRect') and 'CGRect')。为什么我不能简单地比较两个CGRects?

13
更改UIView位置的简单方法?
我使用以下代码更改了UIView的位置,而没有更改视图的大小。 CGRect f = aView.frame; f.origin.x = 100; // new x f.origin.y = 200; // new y aView.frame = f; 是否有更简单的方法仅更改视图位置?
72 ios  layout  uiview  frame  cgrect 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.