Reputation: 8942
I want to show text of one label below the other label.Although text should start from right of first label & it should go below the other label.Please tell me it is possible using ios ?
Upvotes: 2
Views: 634
Reputation: 9599
I got the solution for your question.It is very easy and understandable.
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];
Above in coding i set the helvetica bold and fontsize for reference.If you want to change to systemBold just change and also set the font size according to your requirements.
Thank You-:)
Upvotes: 1
Reputation: 331
At run time display you use NSMutableAttributedString. e.g.
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];
Upvotes: 1
Reputation: 331
Yes this is possible in One label with storyboard.Just use one label and set text as a Attributed.
and select User word and just right click and you find option named as a "Font". now you can select as a Bold,Italic,UnderLine etc.
This is easy way to display text in one Label.
It may be helpful to you.
Upvotes: 0