J'ai créé une vue que je souhaite pouvoir faire pivoter. Les deux vues sont: containerView
et cela a un .backgroundColor
de rouge et BackgroundImage
comme sous-vue. Voici mon code pour faire tourner:iOS - La vue en rotation révèle l'arrière-plan
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self adjustViewsForOrientation:toInterfaceOrientation];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
backgroundImage.image = [UIImage imageNamed:@"landscape.jpg"];
backgroundImage.frame = CGRectMake(0, 0, 1024, 704);
containerView.frame = CGRectMake(0, 0, 1024, 704);
self.title = @"landscape";
} else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
backgroundImage.image = [UIImage imageNamed:@"portrait.jpg"];
backgroundImage.frame = CGRectMake(0, 0, 768, 960);
containerView.frame = CGRectMake(0, 0, 768, 960);
self.title = @"portrait";
}
}
Le problème est que l'image tourne, mais la couleur d'arrière-plan est affichée pendant la rotation de la vue. Y a-t-il une bonne solution à ce problème (je sais que je pourrais créer les images à mélanger dans une couleur et mettre l'arrière-plan à la même couleur, mais ce n'est pas ce que je voudrais).
Une vidéo du problème peut être vu ici: http://tinypic.com/r/2quj24g/6
PS les images sont de la OmniGroup GitHub repo et ne sont utilisées pour la démo.