我正在ViewController
使用一些 UI 元素开发一个,SubViews
但是当我在不同的设备上运行应用程序时,我遇到了这些元素的问题。我正在通过代码做所有事情。我应该使用AutoLayout
吗?我应该如何为这些元素使用自动布局?
我有这些物品:
titleLbl = [[WPCustomLabel alloc] initWithFrame:CGRectMake(30, self.view.frame.size.height/2, 260, 25)];
[titleLbl setFont:[UIFont systemFontOfSize:18]];
[self.view addSubview:titleLbl];
NSLog(@"%f", self.view.bounds.size.height/2);
textLbl = [[WPCustomLabel alloc] initWithFrame:CGRectMake(40, self.view.frame.size.width/2 + 10, 250, 230)];
[textLbl setTextAlignment:NSTextAlignmentJustified];
[self.view addSubview:textLbl];
omitBtn = [[WPCustomButton alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height-108 , self.view.bounds.size.width/2, 44)];
[omitBtn setTitle:@"Omitir" forState:UIControlStateNormal];
[omitBtn addTarget:self action:@selector(omitInfo) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:omitBtn];
nextBtn = [[WPCustomButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height-108, self.view.frame.size.width/2, 44)];
[nextBtn setTitle:@"Siguiente" forState:UIControlStateNormal];
[nextBtn addTarget:self action:@selector(omitInfo) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:nextBtn];