gpt4 book ai didi

ios - 如何为所有屏幕设置两个按钮(一些 x,相同的 y,w,h)

转载 作者:行者123 更新时间:2023-11-29 12:05:02 25 4
gpt4 key购买 nike

我试图得到下面的图像。就像我需要在 viewcontroller 的底部设置两个按钮,它也有一些 Action 。但它不适合所有屏幕。对于 iphone 6,它工作正常,对于 5 和 5s,我所有的按钮都没有显示。这是我需要的图像(button at botton with tansparent background and border color)

enter image description here

这是我用于两个按钮的代码:

  UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height, 200.0, 75.0)];
[button setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0]];
[button setTitle:@"title words" forState:UIControlStateNormal];
[button addTarget:self action:@selector(method:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

UIButton* button1 = [[UIButton alloc] initWithFrame:CGRectMake(180.0, 500.0, 200.0, 75.0)];
[button1 setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0]];
[button1 setTitle:@"title words" forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(method:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];

对于某些屏幕,我的两个按钮在所有屏幕上都没有像我的图像那样显示。而且我还需要将背景设置为透明和一些边框颜色。

请帮帮我,谢谢

最佳答案

让我们考虑在 (320x420) 的 xib 上有两个按钮(B1、B2)的情况,将按钮放在屏幕底部,步骤:

  1. 您的按钮框架将是 B1(0,430,160,50) 和 B2(160,430,160,50)。
  2. 选择两个按钮并单击用于设置约束的固定选项。
  3. 取消标记对边距的限制,从左、右和底部固定也标记纵横比和相等宽度。

在任何设备上运行

根据您的方法,我认为您已经使用 iphone6 xib 设置了约束,因为它不会在较小的设备上显示。

关于ios - 如何为所有屏幕设置两个按钮(一些 x,相同的 y,w,h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35358162/

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