我做了下面的代碼,在屏幕底部獲取標籤,具體取決於設備是iphone5還是iphone4/4s。在屏幕底部放置一個標籤
我想知道我有另一種方式....例如自動佈局?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
CGRect frame;
if ([UIScreen mainScreen].bounds.size.height == 568) {
frame = CGRectMake(140, 500, 320, 100);
} else {
frame = CGRectMake(140, 410, 320, 100);
}
UILabel *iconAdLabel = [[UILabel alloc]init];
iconAdLabel.frame = frame;
iconAdLabel.font = [[UIFont preferredFontForTextStyle:UIFontTextStyleBody] fontWithSize:11.0];
iconAdLabel.text = @"SOME NICE TEXT HERE";
[self.view addSubview:iconAdLabel];
}
是存在與自動佈局另一種方式 – rocky