uiscreen

Capturing full screenshot with status bar in iOS programmatically

瘦欲@ 提交于 2019-11-27 20:39:24
问题 I am using this code to capture a screenshot and to save it to the photo album. -(void)TakeScreenshotAndSaveToPhotoAlbum { UIWindow *window = [UIApplication sharedApplication].keyWindow; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(window.bounds.size, NO, [UIScreen mainScreen].scale); else UIGraphicsBeginImageContext(window.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image =

How to get screen size using code on iOS?

百般思念 提交于 2019-11-27 17:26:49
How to get the iPhone screen size to give calculation? Tim You can use the bounds property on an instance of UIScreen: CGRect screenBound = [[UIScreen mainScreen] bounds]; CGSize screenSize = screenBound.size; CGFloat screenWidth = screenSize.width; CGFloat screenHeight = screenSize.height; Most people will want the main screen; if you have a device attached to a TV, you may instead want to iterate over UIScreens and get the bounds for each. More info at the UIScreen class docs . Here is a 'swift' solution: (Updated for swift 3.x) let screenWidth = UIScreen.main.fixedCoordinateSpace.bounds

What is the difference between -nativeScale and -scale on UIScreen in iOS8+?

∥☆過路亽.° 提交于 2019-11-27 11:20:39
问题 In sample logs posted in this question, the results are identical. Does anyone know if there is meant to be a logical difference between the two? Even Apple's description is confusing. Here is the description of scale : The natural scale factor associated with the screen ... This value reflects the scale factor needed to convert from the default logical coordinate space into the device coordinate space of this screen... Here is their description of nativeScale: The native scale factor for the

Why [UIScreen mainScreen].bounds] is not returning full screen size?

ε祈祈猫儿з 提交于 2019-11-27 07:23:17
问题 I have an app that was created prior to the new iPhone 5 retina widescreen device. Now i am trying to support this high definition widescreen. I adjust the main ViewController and the main window XIB files so that they are set to Autolayout. I can verify that the width/height displayed via the IB shows 320 x 568. However, when I run in simulator, i can see that the height is still 480. The code im using to print the height (and width) is in the main view controller's viewWillAppear method:

UIScreen MainScreen Bounds returning wrong size

浪子不回头ぞ 提交于 2019-11-27 03:55:43
So I created a new project with the latest version of XCode and tried to log the screen size of my app (to determine the device type for UI). I ran the following code from my iPhone 5: NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height); This returned 480 , which is the screen size for the old iPhone family. I tried in the simulator and the same thing happened. Is there some property I have to enable in the project for it to recognize the screen size? This only happens for 5+ devices; if I run the game on my iPad, it recognizes the 1024 screen size. I know for a fact that this code has

How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode?

独自空忆成欢 提交于 2019-11-27 03:51:01
How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode? Is this possible? I've tried [UIScreen mainScreen].scale and it reports 3.0 in both cases. The following code may be used to get bounds , coordinateSpace , nativeScale and scale , i.e. on an iPhone 6 Plus the nativeScale is 2.608 and when the device in run in Zoomed Mode it is 2.88 (note that it is different in the simulator): UIScreen *mainScreen = [UIScreen mainScreen]; NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f", NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace

Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

自闭症网瘾萝莉.ら 提交于 2019-11-26 00:18:52
问题 I ran the following code in both iOS 7 and iOS 8: UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight); NSLog(@\"Currently landscape: %@, width: %.2f, height: %.2f\", (landscape ? @\"Yes\" : @\"No\"), [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); The following is the result from iOS 8: