objective-c – 如何使子视图填充其超视图

前端之家收集整理的这篇文章主要介绍了objective-c – 如何使子视图填充其超视图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在这里找不到答案,也没有看到重复的问题.

我的代码很简单给定3个UIView,parent,from和to,从父中删除添加子视图.添加动画,但只是doodads.

现在,问题是当我这样做,然后被抵消.就好像被推倒了

我甚至添加To.frame = ParentView.frame;以确保它有效.没有

我该怎么做?

+ (void) AnimateSwitchingWithParent: (UIView *) ParentView From: (UIView *) From To: (UIView* ) To
{
    /*[UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];


    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:ParentView cache:YES];*/
    [From removeFromSuperview];
    [ParentView addSubview:To];

    To.frame=ParentView.frame; //If I don't do this,the subview is still off by around 20 points
    NSLog(@"To.bounds: %@",NSStringFromCGRect(To.bounds));
    NSLog(@"From.bounds.: %@",NSStringFromCGRect(From.bounds));
    NSLog(@"ParentView.bounds: %@",NSStringFromCGRect(ParentView.bounds));


    //JA_DUMP (To.bounds);
    //JA_DUMP (To.bounds);



    /*[UIView commitAnimations];*/

}

我已经弄清楚了解决方案.结束To的框架

To.frames:{{0,0},{320,372}}

但是,如果我删除To.frame = ParentView.frame框架也是

{{0,20},460}}

我想知道为什么? 20点似乎是状态栏的距离.我们在哪里可以在InterfaceBuilder中设置该框架?

我在SimulatedMetric部分中将statusbar设置为none.

解决方法

似乎你误解了框架和边界,将你的代码修改为To.frame = ParentView.bounds;应该可以.

相关:Why is there an frame rectangle and an bounds rectangle in an UIView?

原文链接:https://www.f2er.com/c/114200.html

猜你在找的C&C++相关文章