Vous pouvez simplement ajouter une superposition d'un UIView (en couleur noire) sur le dessus.
(Si vous n'avez pas de contrôles dépendants de l'utilisateur dans votre vue (tels que les boutons, les steppers, etc.), alors ceci est correct, par exemple vous avez un UITextView sur UIView, vous pouvez ajouter le UIView noir sur le dessus de UITextView)
(en haut) UIView noir -> UITextView -> UIView
On peut alors contrôler la composante alpha du UIView noir en utilisant
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *touchesArray = [touches allObjects];
for(int i=0; i<[touchesArray count]; i++) {
UITouch *touch = (UITouch *)[touchesArray objectAtIndex:i];
CGPoint point = [touch locationInView:nil];
//set the relationship between point and alpha. Maybe when x increases then alpha increases. You do the math.
}
}
Par ailleurs , définissez noir UIView alpha de 0,0 à 0,7 (souvenez-vous, la mise à plein 1.0 va régler l'écran noir complet.)
Réglage alpha:
[UIView beginAnimations:nil context:NULL]; {
[UIView setAnimationDuration:duration];
[blackView setAlpha:alphaCounter];
} [UIView commitAnimations];