iphone - how to position the dynamically sized label always the center in a view of specific width? -


i had application in had button needs located @ end of dynamic label appending ,i had tried showing times ok (correct position)and times not ok(not @ right position)manner.i doing this.also need position label center `

label = [[uilabel alloc]init];     [label setframe:cgrectmake(105,9,160, 30)];     [label setfont:[uifont fontwithname:@"helvetica-bold" size:18]];     label.textalignment = uitextalignmentleft;     label.numberoflines = 1;     label.text=mystring;     [[self.view viewwithtag:300] addsubview:label];     cgsize expectedlabelsize = [label.text sizewithfont:label.font];      cgrect newframe = label.frame;     newframe.size = expectedlabelsize;     if(newframe.size.width>160.0)       newframe.size.width=150.0;        label.frame = newframe;     [label setcenter:cgpointmake(300/2,40/2)];      button = [uibutton buttonwithtype:uibuttontypecustom];     [button setframe:cgrectmake(newframe.origin.x+newframe.size.width,13,20,20)];     [button setbackgroundimage:[uiimage imagenamed:@"arrow.png"] forstate:uicontrolstatenormal]; 

`can point me in going wrong?

set frame button ..

[button setframe:cgrectmake(newframe.origin.x+newframe.size.width,13,20,20)]; 

your y coordinate fixed need change dynamically


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -