Using 'attributed' label text in Interface Builder Using 'attributed' label text in Interface Builder ios ios

Using 'attributed' label text in Interface Builder


Try This

In my case when i try to set "Silversky Technology" as Attributed text for label from interface builder its not show when i run in simulator but its show in interface builder.So i used one trick i made Silversky font with 1 pixel bigger then Technology text.

Attribute text have issue with same size of font so change size of 1 word this thing work with me.

May be this is xcode bug but this trick work for me.


In Xcode 7.0 beta: I found this is working.

Storyboard:http://imgur.com/Wb5H4ds

Output:

http://imgur.com/iOV8tJF

OR .You can do it dynamically.

-(void)attributedText{UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(20, 100, 200, 44)];NSString *newsTitle = @"Hello";NSString *sportTtle = @"World";NSString *title = [NSString stringWithFormat:@"%@ %@", newsTitle,sportTtle];textView.text = title;UIColor *color = [UIColor redColor];UIFont *font = [UIFont fontWithName:@"Arial" size:20.0];NSDictionary *attrs = @{NSForegroundColorAttributeName : color,NSFontAttributeName:font};NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithAttributedString:textView.attributedText];[attrStr addAttributes:attrs range:[textView.text rangeOfString:sportTtle]];textView.attributedText = attrStr;[self.view addSubview:textView];}


Fonts issue. Workaround for this: clean / clean build folder. Sometimes help./UPDATE: I know this sounds like a "stupid advice" - but it made a trick in my case, so posting it here - to save someone's time maybe.