iPhoneSoft : forum iPhone, iPad, Apple Watch, Apple TV et Mac

application iSoft pour le forum iPhoneSoft (iPhone, iPod, iPad, Apple Watch, Apple TV, Mac et services Apple

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).



#1 15-10-2010 14:18:52

Medhi
Admin

UILabel clignotant avec fond arrondi

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];


Hors ligne

#2 16-10-2010 23:15:35

Medhi
Admin

Re : UILabel clignotant avec fond arrondi

neotux a écrit :

Ma question est peut-être idiote mais c'est quoi un label ?!? roll

Un texte simple smile

Hors ligne

#3 17-10-2010 02:00:11

NAKEDSON
Membre

Re : UILabel clignotant avec fond arrondi

j'ai rien compris O_o

Hors ligne

#4 17-10-2010 22:05:41

NAKEDSON
Membre

Re : UILabel clignotant avec fond arrondi

neotux a écrit :

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

#5 06-02-2011 17:07:14

Re : UILabel clignotant avec fond arrondi

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)


Applications Valicol&Doklyne

Site Internet de VDApps

Hors ligne

Pied de page des forums