iOS 8 Today小部件对齐问题 [英] iOS 8 Today widget alignment issue
问题描述
这是我的故事板
我正在使用autolayout,而不使用大小类。
I'm using autolayout, and NOT using size classes.
当我在iPhone上运行它时5s,它工作正常。(肖像和风景)
When I ran it on iPhone 5s, it works fine.(both portrait and landscape)
但是当我在iPhone 6 plus(肖像)上运行它时,它没有正确对齐。
But when I ran it on iPhone 6 plus (portrait), it's not aligning properly.
on iPhone 6 plus(风景),情况更糟。
on iPhone 6 plus (landscape), it's worse.
I知道我可以使用 -widgetMarginInsetsForProposedMarginInsets:
来设置边距,但在这种情况下,我需要为每个设备自定义边距。这将是可怕的:(
I know I can use -widgetMarginInsetsForProposedMarginInsets:
to set the margin, but in that case I will need to customize the margin for every device. That would be horrible :(
那么有没有办法将子视图与标题对齐不那么痛苦?
So is there a way to align the subview to the title less painfully?
推荐答案
看起来你必须手动设置它。你可以通过创建一个约束,然后为它指定一个IBOutlet,并根据设备/方向设置常量来实现。
Looks like you have to set it manually. You can do this by creating a constraint, then specifying an IBOutlet to it, and setting the constant depending on the device/orientation.
作为参考,以下是我发现你需要的保证金:
For reference, here are the margins I found you needed:
- 5S - 1( 2px)
- 6 - 1(2px)
- 6 plus portrait - 5(15px)
- 6加上风景 - 34(102px)
- 5S - 1 (2px)
- 6 - 1 (2px)
- 6 plus portrait - 5 (15px)
- 6 plus landscape - 34 (102px)
你可以从扩展视图的大小找到你需要的那个,这是414 pt iPhone 6的肖像。
You can find which one you need from the size of the extension view, which is 414 pt for a portrait iPhone 6.
这篇关于iOS 8 Today小部件对齐问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!