Fit width in iOS 8 Today Extensions

a 夏天 提交于 2019-12-17 21:57:49

问题


When I make any iOS 8 Today Extension, there is an empty space on the left of approximately 48px, even if in Interface Builder I place a label on the left side at x=0.



I have seen that some apps, however, use a full-width widget.



How can I achieve something similar?

Thanks!


UPDATE: SOLVED

I put here the sample code because I guess it will be useful to someone. As suggested by @matteo-lallone, the correct way to do this is:

-(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMa‌​rginInsets{
return UIEdgeInsetsZero;
}

回答1:


Straight from the docs:

A Today widget created using the Xcode Today template includes Auto Layout constraints for standard margin insets. To get the inset values for your calculations, implement the widgetMarginInsetsForProposedMarginInsets: method.

Source: App Extension Programming Guide - Today




回答2:


I can supplement the swift version

func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
    return UIEdgeInsetsZero
}

for oc

-(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets {
    return UIEdgeInsetsZero
}

hope it can help someone.



来源:https://stackoverflow.com/questions/25993986/fit-width-in-ios-8-today-extensions

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