ios - How to resize and transform labels? -


my application requires user enter few details displayed via view using labels.

as user can enter variable length of text, while label had fixed length , breadth, used code following adjust label size:

    cgsize maximumlabelsize = cgsizemake(296,9999);          cgsize expectedlabelsize = [yourstring sizewithfont:yourlabel.font                                      constrainedtosize:maximumlabelsize                                      linebreakmode:yourlabel.linebreakmode];               //adjust label the new height.   cgrect newframe = yourlabel.frame;   newframe.size.height = expectedlabelsize.height;   yourlabel.frame = newframe; 

the problem these modifications have many labels 1 after other. when change length of 1 label, following labels need transformed/moved new locations.

is there way can change size , location of labels dynamically, while ensuring final presentation in case of fixed length labels?

 int h=10; // initial height want         for(int k=0;k<[headitemarray count];k++) {             cgsize size_txt_overview1 = [[headitemarray objectatindex:k] sizewithfont:[uifont fontwithname:@"helvetica" size:18] constrainedtosize:constraint linebreakmode:uilinebreakmodewordwrap];             uilabel *lbl_headitem = [[uilabel alloc]initwithframe:cgrectmake(3,h, 690, size_txt_overview1.height)];// see 'h' value             lbl_headitem.text = [headitemarray objectatindex:k];             [lbl_headitem settextalignment:uitextalignmentleft];             [lbl_headitem setbackgroundcolor:[uicolor clearcolor]];             [lbl_headitem settag:k];             lbl_headitem.numberoflines=0;               [lbl_headitem settextcolor:[uicolor redcolor]];             [lbl_headitem setfont:[uifont fontwithname:@"helvetica" size:18]];             [scrollattributes addsubview:lbl_headitem];             h = h + size_txt_overview1.height;// important         }  

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -