如何调整布局大小以适应iOS中的每个屏幕尺寸?

时间:2016-05-08 06:04:46

标签: ios swift ipad autolayout storyboard

我想要的是如果我设计iPad视网膜1024 x 768,当有人在iPad Pro或更小尺寸iPad上使用该应用程序时,所有元素都应调整大小并适合屏幕大小。我不希望我的布局在更大的屏幕尺寸上看起来更小或在更小的屏幕尺寸上看起来更大。我如何实现它?

我现在正在做的是

func getWidthfromConstantForScreenSize(constant: CGFloat, size: CGFloat = 1024, cSize: CGFloat = screenSize.width) -> CGFloat {
    return cSize * (constant / size) // It returns the new size for the screen
}
func getHeightfromConstantForScreenSize(constant: CGFloat, size: CGFloat = 768, cSize: CGFloat = screenSize.height) -> CGFloat {
    return cSize * (constant / size) // It returns the new size for the screen
}

但是对于任何人都知道如何轻松实现它的每一个元素都是一项重大任务?

我正在使用autolayout但我仍然需要以编程方式调整大小。

0 个答案:

没有答案