Mhmt
Mhmt

Reputation: 769

How to create automatically labels by a button?

I have a button,a textfield and some labels.I want create labels by a button display with scroll

Textfield is Number repeat or copy of labels.User when enter 5 to textfield labels will like ;

LabelA LabelB LabelC (Original labels)

LabelA2 LabelB2 LabelC2

LabelA3 LabelB3 LabelC3

LabelA4 LabelB4 LabelC4

LabelA5 LabelB5 LabelC5

Upvotes: 0

Views: 140

Answers (1)

Lithu T.V
Lithu T.V

Reputation: 20021

On button action

  • get the numberOfRows from textfield as [textField.text intValue]
  • Then in a loop Create label programatically setting frame properly

Something like this

For giving you an idea ,not the real working code,this is for snigle column Do for 3 labels added programatically with suitable frame

 for (int i=0; i<[textField.text intValue]; i++)
    {
        UILabel *label= [[UILabel alloc]initWithFrame:CGRectMake(X, Y, Width, height)];
        [self.view addSubview:label];
    }

Upvotes: 2

Related Questions