Forum iPhone, iPod et iPad, Apple TV, Apple Watch et Mac en français par iPhoneSoft pour les systèmes iOS, macOS, tvOS et watchOS
Vous n'êtes pas identifié(e).
Voici comment réaliser un petit label clignotant pour iPhone, iPod et iPad sous XCode :
// on créé un label centré dans la vue, avec un fond blanc et bord vert arrondi
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 100, self.view.frame.size.height/2 - 25, 200, 50)] autorelease];
label.text=@"Bravo !";
label.textColor =[UIColor redColor];
label.backgroundColor = [UIColor whiteColor];
label.layer.borderColor = [[UIColor greenColor] CGColor];
label.layer.borderWidth = 1;
label.layer.cornerRadius = 5;
label.font = [UIFont systemFontOfSize:22];
label.alpha=0.0;
label.textAlignment = UITextAlignmentCenter;
label.autoresizesSubviews = YES;
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin;
// on ajoute le label à la vue
[self.view addSubview:label];
// l'animation
[UIView beginAnimations:@"name" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:1e100f];
[UIView setAnimationDidStopSelector:@selector(nameOfAnimationDidStop:finished:context:)];
label.alpha=1.0; // on lui dit qu'on veut changer la valeur alpha de l'objet label à 1
[UIView commitAnimations];
Fondateur & Expert Mobile
iPhoneSoft : Actu Apple
iPhoneTweak : Jailbreak et Cydia
Hors ligne
Ma question est peut-être idiote mais c'est quoi un label ?!?
Un texte simple
Fondateur & Expert Mobile
iPhoneSoft : Actu Apple
iPhoneTweak : Jailbreak et Cydia
Hors ligne
j'ai rien compris O_o
Hors ligne
C'est pour afficher une sorte de notification, c'est ça ?
Du genre "batterie faible" mais là, ça dit "Bravo !"
Ah ouéééééééééééé genial!
Hors ligne
Non ça c'est une alert view qui peut être crée via des notifications push programmables à l'avance effectivement.
Un label c'est juste un texte dans une application, qui peut changer en fonction d'évènements.
Par exemple dans un jeu du genre doodle jump le score qui tourne est un label
qui fait +1 à chaque fois que le personnage monte (je ne connais pas la frequence mais c'est le principe)
Hors ligne