是否可以在显示之前设置视图的边界

发布于 2024-09-24 02:51:54 字数 762 浏览 2 评论 0原文

-(void)CallingView2{

    SettingsViewController *aSettingsView = [[SettingsViewController alloc] initWithNibName:@"Settings" bundle:nil];

    [self setSettingsViewController:aSettingsView];
    [aSettingsView release];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    //setting the animation
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
    [self.window addSubview:[settingsViewController view]];
    **[[settingsViewController view] setBounds:CGRectMake(0, -30, 320, 480)];**

    [UIView commitAnimations];}

我已将代码放在提交动画的代码中的星星之间,它可以正常工作,它可以按应有的方式移动视图,但现在的问题是,当我旋转到视图时,我可以看到视图何时向下移动。 是否可以在显示之前设置视图的边界,以便用户每次进入设置时都看不到它何时向下移动 30px

-(void)CallingView2{

    SettingsViewController *aSettingsView = [[SettingsViewController alloc] initWithNibName:@"Settings" bundle:nil];

    [self setSettingsViewController:aSettingsView];
    [aSettingsView release];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    //setting the animation
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
    [self.window addSubview:[settingsViewController view]];
    **[[settingsViewController view] setBounds:CGRectMake(0, -30, 320, 480)];**

    [UIView commitAnimations];}

I have put the code between the stars in the code where I commit my animation and it works, it moves the view as it should but now the problem is that when i rotate to the view i can see when the view is moving down.
Is it possible to set bounds for the view before it is shown so the user cant see when it is moving 30px down every time he go to settings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自演自醉 2024-10-01 02:51:54

您的问题是您正在动画块内设置视图边界。在执行翻转过渡期间,视图原点将从 (0,0) 动画到 (0,-30)。

在视图控制器的 viewDidLoad 中设置视图几何形状将是更好的方法。

Your problem is that you're setting the view bounds within an animation block. The view origin will animate from (0,0) to (0,-30) during the time it takes to perform the flip transition.

Setting your view geometry in the view controller's viewDidLoad would be a better approach.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文