iOS获取屏幕宽度

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33351713/article/details/76295604
  • 在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;

猜你喜欢

转载自blog.csdn.net/qq_33351713/article/details/76295604