gpt4 book ai didi

ios - 在屏幕底部放置一个标签

转载 作者:行者123 更新时间:2023-12-01 19:04:22 25 4
gpt4 key购买 nike

我编写了以下代码,以在屏幕底部显示标签,具体取决于设备是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];

}

最佳答案

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

UILabel *iconAdLabel = [[UILabel alloc]init];
iconAdLabel.frame = CGRectMake(0,self.view.frame.size.height-100,320,100);
iconAdLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;

[self.view addSubview:iconAdLabel];

}

关于ios - 在屏幕底部放置一个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20693633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com