Scroll long text inside WKInterfaceLabel?

2019-04-24 13:32发布

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?

4条回答
聊天终结者
2楼-- · 2019-04-24 13:44

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 sample app and it works exactly as you would expect.

Hope that helps!

查看更多
Viruses.
3楼-- · 2019-04-24 13:46

You have to follow these steps respectively to Achieve result like this image.This is a Scrollable View.

enter image description here

I use two groups

Group1: Group1 include image,heading Label,date Label and Group2

Group1 layout is vertical

Width:Relative to Container

Height:Size to Fit Content

Image:

image width:relative to container(0.8)

image height:Fixed(60)

Heading and Date Label:

Width:Relative to Container

Height:Size to Fit Content

Group2: Group2 includes description Label

Group2 layout is vertical

Width:Relative to Container

Height:Size to Fit Content

Description Label:

Width:Relative to Container

Height:Size to Fit Content

查看更多
smile是对你的礼貌
4楼-- · 2019-04-24 13:58

You need to set label's property set height of label as text size

as below

Set Lines Property = 0 (WatchKit auto set the right number)

Set Width = "Relative to Container" & Height = "Size to Fit Content"
查看更多
Lonely孤独者°
5楼-- · 2019-04-24 13:59

It isn't possible to have a WKInterfaceLabel scroll its contents. Your only choice is to truncate the text or allow the label to grow and accommodate it.

查看更多
登录 后发表回答