IPhone/IPad: How to get screen width programmatica

2020-01-26 04:29发布

Hi I'm wondering if there's a way to get the width programmatically.

I'm looking for something general enough to accomodate iphone 3gs, iphone 4, ipad. Also, the width should change based on if the device is portrait or landscape (for ipad).

Anybody know how to do this?? I've been looking for a while... thanks!

7条回答
兄弟一词,经得起流年.
2楼-- · 2020-01-26 05:05

Use this code it will help

[[UIScreen mainScreen] bounds].size.height
[[UIScreen mainScreen] bounds].size.width
查看更多
登录 后发表回答