This is my code.
if UIDevice().userInterfaceIdiom == .phone {
switch UIScreen.main.nativeBounds.height {
case 1136:
print("iPhone 5 or 5S or 5C")
self.pageControl = UIPageControl(
frame: CGRect(
x: 0,
y: 502 ,
width: self.view.frame.size.width,
height: 17
)
)
case 1334:
print("iPhone 6/6S/7/8")
self.pageControl = UIPageControl(
frame: CGRect(
x: 0,
y: 601 ,
width: self.view.frame.size.width,
height: 17
)
)
case 1920, 2208:
print("iPhone 6+/6S+/7+/8+")
self.pageControl = UIPageControl(
frame: CGRect(
x: 0,
y: 670 ,
width: self.view.frame.size.width,
height: 17
)
)
case 2436:
print("iPhone X")
default:
print("unknown")
}
}
if UIDevice().userInterfaceIdiom == .pad {
switch UIScreen.main.nativeBounds.height {
case 1024:
self.pageControl = UIPageControl(
frame: CGRect(
x: 0,
y: 50 ,
width: self.view.frame.size.width,
height: 17
)
)
default:
print("unknown")
}
}
Here when it is iphone the page control will display according the code above.Now i need to do same in ipad.If it is found that it is ipad then place the page control on location which i needed.
But the problem is :-
if UIDevice().userInterfaceIdiom == .pad {
switch UIScreen.main.nativeBounds.height {
case 1024:
self.pageControl = UIPageControl(
frame: CGRect(
x: 0,
y: 50 ,
width: self.view.frame.size.width,
height: 17
)
)
default:
print("unknown")
}
Here i need in such way that :-
- case 1:if it is ipad 9.7
- case 2:ipad 12.9
- case 3:ipad Air 2
- case 4:ipad Air
So how to give?