{"id":1446,"date":"2012-09-26T10:01:37","date_gmt":"2012-09-26T17:01:37","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=1446"},"modified":"2012-09-26T10:01:37","modified_gmt":"2012-09-26T17:01:37","slug":"updating-apps-to-ios6-background-images","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=1446","title":{"rendered":"Updating apps to iOS6 &#8211; Background images"},"content":{"rendered":"<p>The new iPhone is taller than the current phones. The default background images need to have a height (in pixels) of 1136 instead of 960 in the original. background images in the game need to be 176 pixels taller. The actual size depends on what the app does for top and bottom toolbars. Landscape backgrounds need to be 1136 pixels wide.<\/p>\n<p>Since I have lots of games, I wrote a simple shell script to make copies the @2x images for the portrait and landscape and the default. You are required to name the default image &#8216;Default-568h@2x.png&#8217; and iOS will automatically use it when launching on the new iPhone. In fact, that&#8217;s how the phone can tell that an app has been updated for the new dimension\u2014otherwise it runs letterboxes. I kept the naming convention for the rest just to make things consistent.<\/p>\n<p><pre><code class=\"\u2019smaller\u2019 preserve-code-formatting\">\n#!\/bin\/bash\ncd \/Users\/jscarry\/Documents\/Words\/Words\/BG\\ Default-ArticIV\/\ncp BG@2x.png BG-568h@2x.png\ncp BGLandscape@2x.png BGLandscape-568h@2x.png\ncp Default@2x.png Default-568h@2x.png\nexit\n<\/code><\/pre><\/p>\n<p>iOS will not automatically look for background images that fit the new phone\u2019s dimensions. I needed to write a conditional statement to load the correct image if a new iPhone was detected.<\/p>\n<p><pre><code class=\"\u2019smaller\u2019 preserve-code-formatting\">\nUIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; \/\/ iPad doesn&#039;t work with device orientation\n&nbsp;&nbsp;&nbsp;&nbsp;if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ([[Utilities deviceType] isEqualToString:@&quot;iPhone Retina4&quot;]) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@&quot;BG-568h&quot;]];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@&quot;BG&quot;]];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;} else {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ([[Utilities deviceType] isEqualToString:@&quot;iPhone Retina4&quot;]) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@&quot;BGLandscape-568h&quot;]];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@&quot;BGLandscape&quot;]];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre><\/p>\n<p>Note that it will automatically detect the retina display, so you don\u2019t put @2x in the name. I redraw the screen when the device rotates, so I copied this code to the -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration method.<\/p>\n<p>I added a method to my Utilities.m to detect device type. That\u2019s why you see this line:<br \/>\n<pre><code class=\"\u2019smaller\u2019 preserve-code-formatting\">\n[Utilities deviceType] isEqualToString:@&quot;iPhone Retina4&quot;]\n<\/code><\/pre><\/p>\n<p>But all you need to test for is the height:<br \/>\n<pre><code class=\"\u2019smaller\u2019 preserve-code-formatting\">\nif (screenSize.height == 568) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device = @&quot;iPhone Retina4&quot;;\n}\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The new iPhone is taller than the current phones. The default background images need to have a height (in pixels) of 1136 instead of 960 in the original. background images in the game need to be 176 pixels taller. The actual size depends on what the app does for top and bottom toolbars. Landscape backgrounds &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=1446\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Updating apps to iOS6 &#8211; Background images<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-1446","post","type-post","status-publish","format-standard","hentry","category-ios"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1446"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1446\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}