Я строю свой первый WatchKit App и у меня возникают проблемы с NSAttributedString
форматирования, как это, кажется, не работает, как и следовало ожидать;)WatchKit, AttributedString форматирование не работает
Это мой код:
UIFont *textFont = [UIFont fontWithName:@"Menlo" size:30];
UIFont *hlFont = [UIFont fontWithName:@"Menlo-Bold" size:30];
NSMutableAttributedString *information = [[NSMutableAttributedString alloc]initWithString:@"ADDED AN ENTRY OF " attributes:@{NSFontAttributeName : textFont}];
NSString *amountString = [NSString stringWithFormat:@"%.2f",(-1)*handler.amount.floatValue];
NSNumber *underline = [NSNumber numberWithInt:NSUnderlineStyleSingle];
NSAttributedString *amount = [[NSAttributedString alloc]initWithString:amountString attributes:@{NSFontAttributeName : hlFont, NSUnderlineStyleAttributeName : underline }];
NSAttributedString *to = [[NSMutableAttributedString alloc]initWithString:@" TO " attributes:@{NSFontAttributeName : textFont}];
NSString *categoryString = handler.category;
NSAttributedString *category = [[NSAttributedString alloc]initWithString:categoryString attributes:@{NSFontAttributeName : hlFont, NSUnderlineStyleAttributeName : underline }];
[information appendAttributedString:amount];
[information appendAttributedString:to];
[information appendAttributedString:category];
[_informationLabel setAttributedText:information];
и это результат:
Expectation
10.00
и Stuff
должны быть подчеркнуты и выделены жирным шрифтом.
Есть ли что-то принципиально отличное от того, как приписываемые строки работают на часах, чем на iOS? Что мне не хватает?
прочитал это: https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/TextandLabels.html
* будет acceppt за 24 часа –
Не знаете, почему мы не можем использовать шрифты «Menlo» или другой шрифт в яблочных часах? –