简体   繁体   中英

nsarray in uilabel

I want to add uilabels according to mutable array at run time. actually i have some labels texts in nsmutablearray.and i want to create label at run time and fill the text in label.plz suggest any example or provide guidance

If you have an array of NSStrings and you want to create a UILabel for each text you can do:

for(NSString *text in myArray){
    UILabel * label  = [[UILabel alloc] initWithFrame:CGRectMake(...)];
    [label setText:text];
    [aView addSubview:label];
    [label removeFromSuperview];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM