ios 7 view with transparent content overlaps previous view

前端 未结 9 1604
独厮守ぢ
独厮守ぢ 2020-12-23 20:25

Recently I updated my xcode project to work with iOS 7, but i faced a big problem. Because my whole application has only one background image (UIImageView added to key windo

相关标签:
9条回答
  • 2020-12-23 21:01

    Setting the image to the background color solved the issue:

    self.view.backgroundColor = 
                [UIColor colorWithPatternImage:[UIImage imageNamed:@"mainback.png"]];
    
    0 讨论(0)
  • 2020-12-23 21:02

    You might want to look into a new iOS7 feature that allows you to define your own custom UIViewController transitions. Look in the docs for UIViewControllerTransitioningDelegate. Also, here's a link to an article about it: http://www.doubleencore.com/2013/09/ios-7-custom-transitions/

    0 讨论(0)
  • 2020-12-23 21:04

    I had the same problem. Try to load your background image in the init method. For me, it worked (sometimes): For example:

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
            self.view.backgroundColor = [UIColor whiteColor];
            [self.imageBack setImage:[UIImage imageNamed:@"mayBack.png"]];
        }
        return self;
    }
    

    However, you could see glimpses.. The best solution I found, beside implementing the new iOS7 transition protocol, is to implement a category, and use that category whenever you need it. You can find the answer here

    0 讨论(0)
  • 2020-12-23 21:05

    Take a look at the UINavigationController category in that post (it solved me problem) :

    https://stackoverflow.com/a/18882232/2826409

    0 讨论(0)
  • 2020-12-23 21:09

    Ah, now I understand the issue. You were right, seems to be caused by the previous UIViewController not being hidden after the transition (because of the new transition effect).

    There doesn't seem to be any SDK method to control this behavior. Short of redesigning the app to not requiring the background be static, you'll probably have to roll your own navigation. OSNavigationController is a complete reimplementation of UINavigationController that might help you out. If they haven't updated to the iOS 7 transition, you'll probably be good to go. If they have you can always use an older version.

    0 讨论(0)
  • 2020-12-23 21:11

    I did this.

    -(void)viewWillDisappear:(BOOL)animated{
        [super viewWillDisappear:animated];
        [self.view setAlpha:0];
    }
    

    Do not forget re set alpha when come back.

    - (void) viewWillAppear:(BOOL)animated{
        [super viewWillAppear:animated];
        [self.view setAlpha:1];
    }
    
    0 讨论(0)
提交回复
热议问题