wkinterfacelabel

Scroll long text inside WKInterfaceLabel?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 02:19:11
问题 Simple question: is there a way to make a WKInterfaceLabel scroll if its text is too long to fit within the label’s frame? Something akin to a UITextView ? 回答1: You can definitely do this. All you need to do is set the following properties on the WKInterfaceLabel in the Storyboard. Label => Lines = 0 (WatchKit will set the right number) Size => Width = "Relative to Container" Size => Height = "Size to Fit Content" This will let you scroll to your heart's content. I just mocked it up in a

Compare WKInterfaceLabel Text to Another NSString

六眼飞鱼酱① 提交于 2019-12-30 11:59:44
问题 I know there is no getter method for WKInterfaceLabel, but is there another way for me to compare the label text to another string? If this wasn't a watch app and I was using UILabel I could just do this: if ([self.label.text isEqualToString:someString]) { } 回答1: There's no supported way to get the text, just as you said, however you may want to use the accessibility elements as "option". Here's the idea: When self.label text is set (either in code or storyboard) also set the corresponding

How to set alignment for WKInterface Label using setAttributedText

﹥>﹥吖頭↗ 提交于 2019-12-22 10:48:14
问题 I'm trying to set alignment for WKInterfaceLabel using setAttributedText function. Here is my code: var paragraphStyle = NSParagraphStyle.defaultParagraphStyle() paragraphStyle.alignment = NSTextAlignment.Center var attributedDictonary = [NSForegroundColorAttributeName:UIColor.greenColor(), NSParagraphStyleAttributeName:paragraphStyle] var attributeString = NSAttributedString(string: "TextAttributed", attributes: attributedDictonary) self.titleLabel.setAttributedText(attributeString) But I

How to use alternate font weights (e.g. “short”) in a WKInterfaceLabel?

大憨熊 提交于 2019-12-08 03:59:44
问题 In Apple's Apple Watch Design Resources, there is a document called Alternate Font Weights and Italicizations . In it, it shows examples of what the default font looks like with different attributes such as Italic , Emphasized , and Short applied to it. Assume I want to use a font that looks exactly like the "Short" example. Is there any way to choose this font and style via the storyboard for a label? In code, how would I set a label to use this font and style? 回答1: In an iOS project, I

iWatch: WKInterfaceLabel is it possible to stop text from being cut off with “…” at the end of a label?

给你一囗甜甜゛ 提交于 2019-12-07 13:38:29
问题 The text in my WKInterfaceLabel is way too long and causes the text to be cut off with dots at the end. I know for UILabel for iOS you can easily resolve this issue by enabling clip mode. I don't believe there is any way for me to resolve this for watchkit. This is going to force me to use an Image if I can't prevent the text from being cut off. Any tips or suggestions is appreciated. 回答1: You have a couple options depending on how you want the view to respond. In your interface story board

How to use alternate font weights (e.g. “short”) in a WKInterfaceLabel?

拥有回忆 提交于 2019-12-06 04:34:48
In Apple's Apple Watch Design Resources , there is a document called Alternate Font Weights and Italicizations . In it, it shows examples of what the default font looks like with different attributes such as Italic , Emphasized , and Short applied to it. Assume I want to use a font that looks exactly like the "Short" example. Is there any way to choose this font and style via the storyboard for a label? In code, how would I set a label to use this font and style? Senseful In an iOS project, I tried modifying the body font ( UIFontTextStyleBody ) to include UIFontDescriptorTraitTightLeading .

How to set alignment for WKInterface Label using setAttributedText

别说谁变了你拦得住时间么 提交于 2019-12-06 00:58:12
I'm trying to set alignment for WKInterfaceLabel using setAttributedText function. Here is my code: var paragraphStyle = NSParagraphStyle.defaultParagraphStyle() paragraphStyle.alignment = NSTextAlignment.Center var attributedDictonary = [NSForegroundColorAttributeName:UIColor.greenColor(), NSParagraphStyleAttributeName:paragraphStyle] var attributeString = NSAttributedString(string: "TextAttributed", attributes: attributedDictonary) self.titleLabel.setAttributedText(attributeString) But I got a problem with this line: paragraphStyle.alignment = NSTextAlignment.Center I got error: Cannot

iWatch: WKInterfaceLabel is it possible to stop text from being cut off with “…” at the end of a label?

笑着哭i 提交于 2019-12-05 20:04:44
The text in my WKInterfaceLabel is way too long and causes the text to be cut off with dots at the end. I know for UILabel for iOS you can easily resolve this issue by enabling clip mode. I don't believe there is any way for me to resolve this for watchkit. This is going to force me to use an Image if I can't prevent the text from being cut off. Any tips or suggestions is appreciated. You have a couple options depending on how you want the view to respond. In your interface story board select your label and open the attributes inspector. Your first option is to change the font to a smaller