2015-07-02 72 views
0

如何设置归因于标签文本,以便在其他线路上显示的文本.. 我的代码如何设置标签文本归因?

clickLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, 340, 300, 95)]; 
[email protected]"Click on Done,You agree to accept Terms and Conditions and Privacy Policy of Ios App"; 
clickLabel.textColor=[UIColor blueColor]; 
UIFont *boldFont2 = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; 
[clickLabel setFont:boldFont2]; 
[scrollView addSubview:clickLabel]; 
+0

什么部分的文字应该在一个新的行? –

+0

条款和条件 –

+0

clickLabel.attributedText = @“点击完成,您同意接受\ n条款和条件以及Ios应用程序的隐私政策”; 使用\ n在哪里你要开始新行 –

回答

1

对于新生产线的使用\ n和设置numberOfLines超过1如下

clickLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, 340, 300, 95)]; 
[email protected]"Click on Done,You agree to accept \n Terms and Conditions and Privacy Policy of Ios App"; 
clickLabel.numberOfLines = 2; 
clickLabel.textColor=[UIColor blueColor]; 
UIFont *boldFont2 = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; 
[clickLabel setFont:boldFont2]; 
[scrollView addSubview:clickLabel]; 

我希望这会帮助你。

0

要在多行显示使用\nnumberOfLines

clickLabel.text = @"Click on Done, You agree to accept\nTerms and Conditions and Privacy Policy of iOS App"; 
clickLabel.numberOfLines = 0; // 0 mean any number of lines 
+0

因为它不能正常显示...文本太长,在这里 –

+0

Nesha尝试以上。 –

0

你可以不喜欢它这样的:

NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString:@"YOUR_STRING"]; 

clickLabel.attributedText = attrStr; 

和一举两得:

  • clickLabel.numberOfLines = 2;
  • 在您的文字前添加\ n。
1

您是否试过这种解决方案?

clickLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, 340, 300, 95)]; 

clickLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Click on Done,You agree to accept\nTerms and Conditions and Privacy Policy of Ios App" attributes:nil] ; 

clickLabel.textColor=[UIColor blueColor]; 

clickLabel.numberOfLines = 0; 

UIFont *boldFont2 = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; 
[clickLabel setFont:boldFont2]; 
[scrollView addSubview:clickLabel]; 
0

它的工作原理是为clickLabel设置合适的高度。

UILabel * clickLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, 340, 300, 100)]; 
clickLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Click on Done,You agree to accept\nTerms and Conditions and Privacy Policy of Ios App" attributes:nil] ; 
clickLabel.textColor=[UIColor blueColor]; 
clickLabel.numberOfLines = 0; 
UIFont *boldFont2 = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; 
[clickLabel setFont:boldFont2]; 
[self.view addSubview:clickLabel];