开发者

dynamically adding label at the end another label

hi i have a scroll view and in that scrollview i have label and and i have a dynamic text for that label .....

and i am adding another label to the scroll view at the end of the first lable.....

and the code is as follows....

UILabel *lblGenericName   = [self createDynamicLabel:responseDr开发者_Go百科ugInfo.GenName
                                        contentFrame:CGRectMake(120, 24, 150, 20) 
                                               color:[UIColor customisedlightgreysColor] 
                                                font:[UIFont regular14]];
[scrollview addSubview:lblGenericName];
[lblGenericName release];

lblGenericName.numberOfLines = 0;

[lblGenericName sizeToFit];

now i want to add dynamically another label at the end of that label ...

can any one please help me how to do that........


Try this

UILabel *newLabel = [self createDynamicLabel:responseDrugInfo.GenName
                                    contentFrame:CGRectMake(lblGenericName.frame.origin.x + lblGenericName.frame.size.width, lblGenericName.frame.origin.y, lblGenericName.frame.size.width, lblGenericName.frame.size.height) 
                                           color:[UIColor customisedlightgreysColor] 
                                            font:[UIFont regular14]];
[scrollview addSubview:newLabel ];


As you have to add another Label after first

Simply create another label dynamically after i.e.newlabel.x=(originallabel.x+originallabel.width)

Hope it helps...


If u want to add your label to the right of the label By using Change the x position is but do not change the y position of your label frame

label2X =label1X + label1.width;

UILable * label2 =[[UILabel alloc] initWithFrame :CGRECTMake(label2X, 24 , 150, 30)];

[scrollview addSubview:lblGenericName]; [label2 release];

it works

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜