更新一些旧代码,并修复了UIView
中一个讨厌的按钮之外的所有问题,该按钮仅在某些设备上无法正确显示。
它适用于所有iPad设备,并且位置完美,并且适用于iPhoneX / XS和XR
但是,对于iPhone 5,5s,6,6s,7,8,按钮未正确显示。
我知道这是一个“肮脏”的修复程序,但是实际上这是一个导致问题的按钮,其余代码本身运行正常,所以我不想像这样重新发明轮子。
图像位置本身是这样设置的;
#define IDIOM UI_USER_INTERFACE_IDIOM()
#define IPAD UIUserInterfaceIdiomPad
if ( IDIOM == IPAD ) {
[nail5View setFrame:CGRectMake(638, 682, nail5View.frame.size.width, nail5View.frame.size.height)]; // was 358,582
} else {
[nail5View setFrame:CGRectMake(358, 582, nail5View.frame.size.width, nail5View.frame.size.height)];
}
nail5View.autoresizingMask = UIViewAutoresizingNone;
transform = CGAffineTransformMakeRotation(+0.9);
nail5View.transform = transform;
有没有办法我可以专门针对低于X的iPhone添加一个额外的位置呢?
最佳答案
您可以检查设备是否为iPhone 8plus或更低型号,例如thise
#define iPhone8AndLesser ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height <= 736)
如果要使用iPhone 8,请使用736装667
您可以使用进行检查
if ( IDIOM == IPAD ) {
[nail5View setFrame:CGRectMake(638, 682, nail5View.frame.size.width, nail5View.frame.size.height)]; // was 358,582
} else {
if iPhone8AndLesser{
//Your conditions here;
}else{
[nail5View setFrame:CGRectMake(358, 582, nail5View.frame.size.width, nail5View.frame.size.height)];
}
}
关于ios - 在声明中调整iPhoneX/iPad/iPhone6的UIView位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60990765/