How to set the height of a Today Widget Extension?

后端 未结 6 1826
心在旅途
心在旅途 2020-12-12 18:13

How can i change the height of my App\'s Today Extension in the Notification Center?

I tried it with the Interface Builder and with Code, the Interface Builder Displ

6条回答
  •  旧巷少年郎
    2020-12-12 18:41

    Widgets have their heights adjusted by the system. If you have defined your height using constraints this will be automatically adjusted as required. If you're using explicit layout you can request a new height by modifying the preferredContentSize of your widget.

    Note that you have no guarantee notification center will respect your height request: it may be adjusted automatically, it may be adjusted but not to the exact height you want, or it may not be honored at all.

    The best way to develop a widget is to use auto-layout constraints to set your height values, that way your widget will adapt to different heights with ease.

提交回复
热议问题