我需要制作动态高度和y原点的UILabel(4)。我知道第一个标签的y原点。但是它的高度,行数应该根据动态变化的内容而变化。所以根据到第一个标签,第二个标签的y-origin应该开始和第一个相同,它应该根据内容自动调整其高度和行数。就像第三个和第四个标签一样
这是我需要获得的格式:
Name: Wilston Works
Working Days: Sun,Mon,Tue,Wed,Thu, // Here only upto Thur then Workinh hrs should start after that
Fri
Working hrs:9 to 5
Specialities:General,parties,festival
specials,..............
....... //lines depends on content may be 1 to many
我的代码:
displayName =[[UILabel alloc] init];
[displayName setFrame:CGRectMake(10, companyaccess.frame.size.height+companyaccess.frame.origin.y,300, 30)]; //companyaccess is the label above this label
displayName.textAlignment = UITextAlignmentLeft;
displayName.backgroundColor = [UIColor clearColor];
self.displayName.text= [NSString stringWithFormat:@" Name :"];
[displayName setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[self.view addSubview:displayCompanyName];
NSString *displayname1=[NSString stringWithFormat:@"%@",id1];
CGSize constraint6 = CGSizeMake(250, 2000.0f);
CGSize size6=[displaycompanyname1 sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:14] constrainedToSize:constraint6 lineBreakMode:UILineBreakModeWordWrap];
displayName1 =[[UILabel alloc] init];
[displayName1 setFrame:CGRectMake(155,companyaccess.frame.size.height+companyaccess.frame.origin.y,self.view.bounds.size.width,30) ];
displayName1.textAlignment=UITextAlignmentLeft;
displayName1.backgroundColor=[UIColor clearColor];
[displayName1 setNumberOfLines:0];
[displayName1 sizeToFit];
displayName1.text=[NSString stringWithFormat:@"%@ " ,displayname1];
displayName1.highlightedTextColor=[UIColor blackColor];
[displayName1 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14]];
[self.view displayName1];
displayWorkingDays=[[UILabel alloc] init];
[displayWorkingDays setFrame:CGRectMake(10,displayName1.frame.size.height+displayName1.frame.origin.y,self.view.bounds.size.width,30)];
displayWorkingDays.textAlignment=UITextAlignmentLeft;
displayWorkingDays.backgroundColor=[UIColor clearColor];
displayWorkingDays.text=[NSString stringWithFormat:@"Working Days :"];
[self.view addSubview:displayWorkingDays];
displayWorkingDays1=[[UILabel alloc] init];
[displayWorkingDays1 setFrame:CGRectMake(150,displayName1.frame.size.height+displayName1.frame.origin.y,self.view.bounds.size.width,40)];
displayWorkingDays1.numberOfLines=0;
displayWorkingDays1.textAlignment=UITextAlignmentLeft;
displayWorkingDays1.backgroundColor=[UIColor clearColor];
displayWorkingDays1.text=[NSString stringWithFormat:@"%@",temp1];
displayWorkingDays1.font=[UIFont fontWithName:@"arial" size:14];
[displayWorkingDays1 sizeToFit];
[self.view addSubview:displayWorkingDays1];
............// for all the labels.But I could not get what i desired.
}
请给我一个满足上述标准的gud示例.bcoz我试过的所有在某些情况下工作但在其他情况下无法工作。
任何帮助都会受到赞赏。