简体   繁体   English

在其他iOS设备上调整应用大小?

[英]resize my app on another iOS devices?

Iv'e made an app for for iPhone 5, now i want to make it available for another iOS devices, but i don't know how to resize the label in different sizes. Iv为iPhone 5制作了一个应用程序,现在我想使其可用于其他iOS设备,但是我不知道如何将标签调整为不同的大小。

I've got a label that change his point by the iPhone 5 size: 我有一个标签可以通过iPhone 5尺寸改变他的观点:

    if (a == true) {
self.minutes.frame = CGRectMake(271, 109, 140,100)
}

I used to play with the auto layouts but the label always "jumps" to here: 我曾经玩过自动布局,但是标签总是“跳到”这里:

CGRectMake(271, 109, 140,100)

and back to his first place. 回到他的第一名。

How can i fix it. 我该如何解决。 Thank you 谢谢

You can test for the different iphone sizes 您可以测试不同的iPhone尺寸

if(  UIScreen.mainScreen().bounds.size.width == 568)

{self.minutes.frame = CGRectMake(271, 109, 140,100)}

else if(UIScreen.mainScreen().bounds.size.width == 667 )

{ change to the size that looks best in iphone 6 }

else if(UIScreen.mainScreen().bounds.size.width == 736 )

{ change to the size that looks best on iphone 6 plus }

else

{ change to the size that you want for the smaller devices }

You should definitely be using AutoLayout for this, if you tried you need to make sure you edit the constraints to change the position or size of views instead of setting the frame . 您绝对应该为此使用AutoLayout,如果尝试过,则需要确保编辑约束以更改视图的位置或大小,而不是设置frame Here is a good tutorial that introduces AutoLayout: http://www.appcoda.com/introduction-auto-layout/ 这是介绍AutoLayout的很好的教程: http : //www.appcoda.com/introduction-auto-layout/

Also, UILabel has an intrinsic content size (the size depends on the text and font), therefore you shouldn't be changing it's size manually. 而且, UILabel具有固有的内容大小(大小取决于文本和字体),因此您不应该手动更改其大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM