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

Hope that helps!




回答2:


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.




回答3:


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"



回答4:


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

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



来源:https://stackoverflow.com/questions/29110184/scroll-long-text-inside-wkinterfacelabel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!