如何在 iOS 中显示两个标签文本?
How to show two one label text below other in iOS?
我想在另一个标签下方显示一个标签的文本 label.Although 文本应该从第一个标签的右侧开始并且应该在另一个标签下方 label.Please 告诉我可以使用 ios ?
是的,这在 storyboard.Just 的一个标签中是可能的,使用一个标签并将文本设置为属性。
and select User word 然后右击你会发现名为“Font”的选项。现在您可以 select 作为粗体、斜体、下划线等
这是在一个标签中显示文本的简单方法。
可能对你有帮助。
在 运行 时间显示您使用 NSMutableAttributedString。
例如
NSDictionary *dicAttributes = @{NSForegroundColorAttributeName:WHITE_COLOR, NSFontAttributeName: UI_DEFAULT_ROBOTO_BOLD(15.0)};
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:@"here is your text which want to set" attributes:dicAttributes];
我得到了你的解决方案 question.It 非常简单易懂。
NSMutableAttributedString *mutableAttributeStr = [[NSMutableAttributedString alloc]initWithString:@"User this is just a comment.This just a comment.This just a comment."];
NSAttributedString *attributeStr = [[NSAttributedString alloc]initWithString:@"\n" attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:8]}];
[mutableAttributeStr addAttribute:NSFontAttributeName value: [UIFont fontWithName:@"Helvetica-Bold" size:14.0] range:NSMakeRange(0, 4)];
[mutableAttributeStr appendAttributedString:attributeStr];
labelTextBelowAnotherLabel.numberOfLines = 0;
[labelTextBelowAnotherLabel setAttributedText:mutableAttributeStr];
在上面的编码中,我为 reference.If 设置了 helvetica 粗体和字体大小,你想更改为 systemBold 只需更改并根据你的要求设置字体大小。
谢谢-:)
我想在另一个标签下方显示一个标签的文本 label.Although 文本应该从第一个标签的右侧开始并且应该在另一个标签下方 label.Please 告诉我可以使用 ios ?
是的,这在 storyboard.Just 的一个标签中是可能的,使用一个标签并将文本设置为属性。
and select User word 然后右击你会发现名为“Font”的选项。现在您可以 select 作为粗体、斜体、下划线等
这是在一个标签中显示文本的简单方法。
可能对你有帮助。
在 运行 时间显示您使用 NSMutableAttributedString。 例如
NSDictionary *dicAttributes = @{NSForegroundColorAttributeName:WHITE_COLOR, NSFontAttributeName: UI_DEFAULT_ROBOTO_BOLD(15.0)};
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:@"here is your text which want to set" attributes:dicAttributes];
我得到了你的解决方案 question.It 非常简单易懂。
NSMutableAttributedString *mutableAttributeStr = [[NSMutableAttributedString alloc]initWithString:@"User this is just a comment.This just a comment.This just a comment."];
NSAttributedString *attributeStr = [[NSAttributedString alloc]initWithString:@"\n" attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:8]}];
[mutableAttributeStr addAttribute:NSFontAttributeName value: [UIFont fontWithName:@"Helvetica-Bold" size:14.0] range:NSMakeRange(0, 4)];
[mutableAttributeStr appendAttributedString:attributeStr];
labelTextBelowAnotherLabel.numberOfLines = 0;
[labelTextBelowAnotherLabel setAttributedText:mutableAttributeStr];
在上面的编码中,我为 reference.If 设置了 helvetica 粗体和字体大小,你想更改为 systemBold 只需更改并根据你的要求设置字体大小。
谢谢-:)