TERMINAL RESOLUTION ACQUISITION METHOD FOR iOS

Asked 2 years ago, Updated 2 years ago, 43 views

http://www.dorapro.co.jp/engineerblog/?p=255

iPhone 6 Plus/iPhone 6s Plus 5.5 inch 1920 x 1080 16:9

on

I want to get the screen resolution as terminal information by Swift, but I don't know how to get it.

Please let me know

ios swift objective-c

2022-09-29 22:40

2 Answers

The iPhone 6 Plus returns a value of 1080x1920 in the UISscreen.nativeBounds property.

 print (UISscreen.mainScreen().nativeBounds)

If you run the above on an iPhone 6 Plus device,

 (0.0, 0.0, 1080.0, 1920.0)

returns the .


2022-09-29 22:40

The resolution (2208.0 121242.0) can be obtained by the following process, but the iPhone 6 Plus seems to be a little special, so the 1920x1080 value cannot be obtained.

let size=UISscreen.mainScreen().bounds.size
let scale = UISscreen.mainScreen().scale
let result = CGSizeMake (size.width*scale, size.height*scale)

print(result.height)//2208.0
print(result.width)//1242.0

↓Reference URL
http://qiita.com/YukiAsu/items/78a5bed63c12660e8024


2022-09-29 22:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.