- 在AppDelegate.h文件中声明一个全局变量:
@property int currentWidth;//当前屏幕宽度 - 在AppDelegate.m中,添加:@synthesize currentWidth;
- 然后在
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions 中添加:
currentWidth=[UIScreen mainScreen].bounds.size.width; - 在需要使用的地方声明一个变量令其等于该变量:
width=delegate.currentWidth;
iOS获取屏幕宽度
最新推荐文章于 2020-04-01 09:40:42 发布