虽然我是iOS的新手,但我还是向设计师要了一个应用程序。他只给了我iPhone 6的设计指南。
如何将本设计指南应用于分辨率较低、比例不同的iPhone 4S等其他设备。
我该如何应用设计指南?我目前正在使用自动布局,但我并不完全理解自动布局。
这个问题有没有参考资料?
发布于 2016-06-15 19:58:54
如果你是新手,那么你必须知道如何通过编程来检测你正在使用的设备。这些是macros使用它们来检测
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)现在你可以使用它们来制作任何视图,比如如果你想创建宽度为屏幕尺寸,高度为100的按钮。
然后就可以通过编程方式为任何设备创建按钮了
float screenWidth=[UIScreen mainScreen].bounds.size.width;
float screenHeight=[UIScreen mainScreen].bounds.size.height;
UIButton *btnLock=[UIButton buttonWithType:UIButtonTypeCustom];
btnLock.frame= CGRectMake(0, 50, screenWidth, 100);
btnLock.backgroundColor=[UIColor redColor];
[self.view addSubview:btnLock];如果你想以编程的方式进行编码,这是一种方法。谢谢
发布于 2016-06-15 20:58:03
float screenWidth=[UIScreen mainScreen].bounds.size.width;
float screenHeight=[UIScreen mainScreen].bounds.size.height;
int padding = 10;
UIButton *btnLock=[UIButton buttonWithType:UIButtonTypeCustom];
btnLock.frame= CGRectMake(padding, 50, screenWidth-padding*2, 100);
btnLock.backgroundColor=[UIColor redColor];
[self.view addSubview:btnLock];这将为每个iPhone提供10个填充。试试看,谢谢
https://stackoverflow.com/questions/37834391
复制相似问题