In Swift, you can determine the screen size of an iPhone 4 or iPhone 5 by checking the bounds of the UIScreen object. Here's an example code snippet that shows how to do this:
let screenSize = UIScreen.main.bounds.size
if screenSize.height == 480 {
print("iPhone 4 screen size")
} else if screenSize.height == 568 {
print("iPhone 5 screen size")
} else {
print("Not an iPhone 4 or 5")
}
This code first gets the size of the main screen using the bounds
property of the UIScreen
object. It then checks the height of the screen size, and if it matches the height of either iPhone 4 or 5, it prints the appropriate message.
Asked: 2022-05-05 11:00:00 +0000
Seen: 12 times
Last updated: Apr 25 '22