UIScreen相关

UIScreen类代表了屏幕,通过这个类我们可以获取一些屏幕相关信息

CGRect screenBounds = [ [UIScreen mainScreen]bounds];    //返回的是带有状态栏的Rect 
CGRect viewBounds = [ [UIScreen mainScreen]applicationFrame];    //不包含状态栏的Rect  

//screenBounds 与 viewBounds 均是相对于设备屏幕来说的  
//所以 screenBounds.origin.x== 0.0 ;   screenBounds.oringin.y = 0.0;     
screenBounds.size.width == 320;  screenBounds.size.height == 480(或者其他分辨率有所差异)  
//所以 screenBounds.origin.x== 0.0 ;   screenBounds.oringin.y = 20.0;(因为状态栏的高度是20像素)   screenBounds.size.width == 320;  screenBounds.size.height == 480  
//取得StatusBar的位置和大小  
[self.view addSubview:theToolbar];  
CGRect statusBarRect = [[UIApplication sharedApplication]statusBarFrame];  

NSLog(@\"%@\", NSStringFromCGRect(statusBarRect));

results matching ""

    No results matching ""