Crear una etiqueta en IBAction
Frecuentes
Visto 178 veces
0
I want to make it so when a button is clicked this a label comes up and will eventually animate. I made a start but this label does not show up at all. The CGRect coords are correct I am using a 3 page wide scroll view. Anyway, here is the code
UILabel *plusSymbol = [[UILabel alloc]initWithFrame:(CGRectMake(987, 349, 330, 326))];
plusSymbol.text = [NSString stringWithFormat:@"+%f", applesPerClick];
2 Respuestas
0
try adding the label to the button.
UIButton *btn;
UILabel *label;
[btn addSubview:label];
Respondido el 22 de Septiembre de 13 a las 18:09
0
When you create a view or button or anything from code you have to add to the screen:
UILabel *plusSymbol = [[UILabel alloc]initWithFrame:(CGRectMake(987, 349, 330, 326))];
plusSymbol.text = [NSString stringWithFormat:@"+%f", applesPerClick];
[self.view addSubview:plusSymbol];
//[yourParentView addSubview:plusSymbol];
If you want to add on the Button
[yourButton addSubview:plusSymbol];
But be careful because the frame is in your parentView. if your button is 100*100 then you have to modify the plusSymbol.frame
. plusSymbol.frame = CGRectMake(0, 0, 100, 100);
Respondido el 22 de Septiembre de 13 a las 18:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios objective-c cocoa-touch or haz tu propia pregunta.
did you add the label as a subview? - Wain
I assume not, how would I do this? - SHERRIE CRANE