Avatar ·

How to determine iOS device screen size in Swift?

Hello everyone! I'm a beginner in iOS development with Swift and encountered a problem when trying to get the device screen size. I need to adapt the interface for different screen sizes (iPhone SE, iPhone 12, iPad, etc.), but I can't figure out how to do it correctly. I tried several methods, but they either return incorrect values or don't work at all. Here's what I tried: ```swift let screenSize = UIScreen.main.bounds.size print("Screen size: \(screenSize)") ``` But this code seems to work, though I read that `UIScreen.main` might be deprecated or unreliable in some cases. I also heard that I need to consider safe area and navigation bar, but I don't understand how that affects the screen size. I also tried using `UIApplication.shared.keyWindow?.bounds`, but this