【问题标题】:How do I set the page curl bottom side background color/image during the transition animation?如何在过渡动画期间设置页面卷曲底侧背景颜色/图像?
【发布时间】:2012-03-19 00:20:27
【问题描述】:

我正在使用UIViewAnimationOptionTransitionCurlUp 过渡动画在我的应用程序中的视图之间进行过渡。然而,页面卷曲底部的标准白色背景在我的应用程序中看起来很难看。如何更改“页面”背面的背景颜色(或图像)?

我尝试了这两个页面上发布的建议但没有成功:

How do I control the background color during the iPhone flip view animation transition?

http://adrianhosey.blogspot.com/2009/04/putting-background-behind-uiview.html

根据上述链接帖子中的建议,我尝试通过将以下代码添加到 viewDidLoad: 来向视图和窗口添加子视图,但这也不起作用:

UIView *dummyView = [[UIView alloc] initWithFrame:self.view.window.frame];
dummyView.backgroundColor = [UIColor blueColor];
[self.view addSubview:dummyView];
[self.view.window addSubview:dummyView];

作为参考,这是我的动画代码:

[UIView transitionWithView:self.view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionCurlUp|UIViewAnimationCurveEaseIn
                animations:^{}
                completion:^ (BOOL success){
                   // do some stuff here
                }];

有什么想法吗?

【问题讨论】:

    标签: iphone objective-c ios animation uiview


    【解决方案1】:

    把这段动画卷起来的代码放上去.....

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.80];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp 
                           forView:self.navigationController.view cache:NO];
    [self.navigationController pushViewController:self.detailviewcontyrollerObj animated:YES];
    [UIView commitAnimations];
    

    希望这会有所帮助...:)

    【讨论】:

      【解决方案2】:

      您也可以在您的 appDelegate 的 application didFinishLaunchingWithOptionsmethod 中尝试此操作:

      [window makeKeyAndVisible];
      
      window.layer.contents = (id)[UIImage imageNamed:@"yourImageName"].CGImage;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-08
        • 2011-08-12
        • 2014-07-22
        • 2023-03-10
        • 1970-01-01
        • 2022-12-23
        相关资源
        最近更新 更多