我在这里找不到答案,也没有看到重复的问题.
我的代码很简单给定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.jb51.cc/c/114200.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。