- 在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获取屏幕宽度的全部内容,更多相关iOS获取屏幕宽度内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复