Lines and Design For Retina [duplicate] - iphone

This question already has answers here:
Can you have a 0.5px border on a Retina Display?
(10 answers)
Closed 9 years ago.
I have a quick question, as all of my searches have turned up app design and not web design answers.
When designing for Retina, what should I put in my CSS to make a 1px horizontal line appear as just that - 1px? I don't want it doubling up, but I also can't make it 0.5px apparently.
Or does it render pixel-specified borders as it should?
Everything I've looked into so far just makes it so much more confusing.

I'm assuming from your tags on the question, that you have a 1px border created in CSS. There is no need to adjust the border for high density displays. When the border is rendered by the browser, whatever calculations that need to be made for it, will be. So, you'll get a crisp 1px border in any scenario.
Unfortunately, I cannot locate a resource that states this explicitly. However, I know from my personal experience (developing websites, including mobile) that I never make any adjustments to border thickness for high density displays. I only do this for graphics.
This is one of many reasons why using CSS to create your graphics is useful.

Related

the best way to handle dark mode logos in html emails

am designing a html email template that supports dark mode for all email clients but am facing a problem with the logo.
The logo is a black .png image and the default/light background is white, so in dark mode it becomes black over black. Adding an outline to the logo is not an option, using 2 images with classes and controlling which one to display using media queries won't work for Gmail ios and some outlook versions, so am left with three choices but am not sure wither they are applicable and supported by all famous clients:
forcing the white background by using a gradient as the background-color value instead of a hex value
using this method that I found online for webpages:
<picture>
<source srcset="dark-mode.png" media="(prefers-color-scheme: dark)">
<img src="light-image.png">
</picture>
using an SVG instead of the image so the fill color will change.
So, are any of them is applicable and supported?
Also, more suggestions/ideas/options are appreciated.
Support for SVG is quite limited so unfortunately that's not an option: https://www.caniemail.com/features/image-svg/
#media prefers-color-scheme: dark is not supported on Gmail/some Outlooks, so that's not going to work. https://www.caniemail.com/features/css-at-media-prefers-color-scheme/
Using a gradient to force unchanging background is not ideal (we should be supporting customer's preferences), and also not 100% cross-compatible. (background-image: linear-gradient(#ffffff,#ffffff);)
If a 1px white stroke is no good for you, you could try a soft glow like Litmus do.
Alternatively, sometimes we just end up putting a single-colour background in the image itself (i.e. getting rid of the transparency), perhaps with rounded corners (a tiny bit of transparency on the corners). Works best for icons, but might be your only option.

Most ergonomic way to present text info on iPhone

What is the best and most ergonomic way to present info on an iPhone?
I currently have a simple GPS-type app that on one view shows the map and on another all the movement data such as speed, altitude, heading and co-ords. I show these few variables (which are constantly changing) with white font on a black background.
The font I currently use: Helvetica, 24.0
This app will actually be used in driving conditions so it has to be good on the eye and readable in many conditions, e.g. at night. Obviously it will be readable, but what is the most ergonomic option, looking at these aspects:
Font Family (AKA Type, e.g. Helvetica)
Font Color
Font Size
Background Color
I've found that white on black works very well on these displays. For one thing, it makes the whole phone one solid black area (if the phone is black), and the text stands out at a glance. I would consider using Helvetica Bold rather than Helvetica. But I think Helvetica is a good choice because it's the standard on the iPhone, and people will expect it. As for font size, with a GPS I'd much prefer text to err on the side of being large than being small. People will forgive a little cramping in the map display if you give the text a size boost.

Single/sub pixel misalignment of divs on ipad and iphone safari

I've got the following situation, and I need some help...
Two divs, same size, same location, one on top of the other
Everything works as expected on desktop browsers
On the iphone/ipad a faint line appears around the border of the divs
This faint line is not always on all four borders. It changes depending on the location of the divs. It looks to be happening as a result of the two divs not lining up properly, but according to their style settings, they are of identical size and location.
You can see the results here: http://www.thoughtartistry.com
Any ideas?
I had a similar problem in a recent project where I had background image masks with different background color to colorize the resulting icons in mobile Safari. The problem was that when the page was scaled down by Safari, there was a line of the background color showing around the image, even though it should have been masked. I never found a way to prevent that leaking of the background color when the page is scaled down. It's clearly an error in mobile Safari's algorithms that recalculate the background and mask. I did find a workaround: I put an outline on the element with the same color as the background of the element's parent. The outline is outside the element and therefore masks the part bleeding out. If your element's parent has a pattern background that's drastic, this won't work that well, but if it's a solid color, it'll do just fine.
A negative margin is the only way I found to prevent this.
For example, if you have a faint horizontal gap between 2 divs, adding a top margin of -1px to the second div will make it overlap slightly and the gap will not reappear as the page is scaled.
Some situations (like image sprites or repeat patterns) may need a little more tweaking, but the general idea is the same. For a sprite, make sure there is no big color change within 1 pixel of the cropping border. The bleed is never more than 1 pixel, so a 1 pixel adjustment is enough.
The problem is not only with divs matching together, but also with image sprites.
I followed the advise in this thread of setting initial viewport scale to 1.0. The sub-pixel bug was gone, but then I tested my website on other devices, like Android, and realized a full size page is annoying, since users have to re-scale every time it's loaded. So I preferred to disable the scale and wait until Apple fixes it. Then one day I was thinking how to solve the problem with the margins of the page, and I came to this simple solution in CSS:
html {
min-width: 1024px;
}
Devices capable of this resolution, such as iPad in horizontal position, will set the document scale to 1.0. In my case this is enough solution, since I can show the page is working just right, and the sub-pixel bug is in Safari/iOS, which will be solved in the future hopefully.
It totally depends on one's situation, but in our case we use negative margins as proposed by this thread or a box shadow since outline only applies to all borders and ie. outline-bottom does not exist.
/*
* Prevent faint lines between elements.
* #link http://stackoverflow.com/questions/5832869
*/
box-shadow: 0 1px 0 red;
I also solved the iOS sub pixel gap issue (on a full screen site) by using overflow-x: hidden; to stop side ways scrolling & viewpoint scale to stop pitch zooming. I also had holder divs set at width: 101%; and all the elements/image divs inside set to float: left;. This means the sub pixel gaps are all on the left hand site but pushed out of view by the holder div set at 101% width.
Remove "clear:both" (if there is) from div below the gap.
I also had to solve this. If you are using Div's to define sections only then.
//background.css
.background-color {
background-color: blue;
}
.background-color div {
background-color: inherit;
}
I'd try playing with meta/viewport options, specifically setting initial scale to 1.0 and disabling user zooming.
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

iPhone App Icons - Exact Radius?

I'm trying to create the icon for my iPhone app, but don't know how to get the exact radius that the iPhone's icons use. I've searched and searched for a tutorial or a template but can't find one.
I'm sure that I'm just a moron, but how do you get the rounded corners exactly right with your icon from Illustrator or Photoshop?
Edit:
What's the radius for the Retina iPad?
You can make four icons (as of today) for your app and they can all have a different look - not necessarily based on the 512x512 image.
corner radius for the 512x512 icon = 80 (iTunesArtwork)
corner radius for the 1024x1024 icon = 180 (iTunesArtwork Retina)
corner radius for the 57x57 icon = 9 (iPhone/iPod Touch)
corner radius for the 114x114 icon = 18 (iPhone/iPod Touch Retina)
corner radius for the 72x72 icon = 11 (iPad)
corner radius for the 144x144 icon = 23 (iPad Retina)
If you do create a set of custom icons, you can set the UIPrerenderedIcon option to true in your info.plist file and it will not add the gloss effect but it will place a black background under it and still round the image corners with these corner radii so if the corner radius on any of the icons is greater then it will show black around the edges/corners.
Edit: See comment from #devin-g-rhode and you can see that any future icon sizes should have a 1:6.4 ratio of corner radius to icon size. There is also a very good answer from https://stackoverflow.com/a/29550364/396005 which has the location of image mask files used in the SDK for rounding icon corners
To add a retina-compatible file, use the same file name and add '#2x'. So if I had a file for my 72x72 icon named icon.png, I would also add a 114x114 PNG file named icon#2x.png to the project/target and Xcode would automatically use that as the icon on a retina display. You can see this in action on the Summary page of the application target if you've done it right. The same works for your launch images. Use launch.png at 320x480 and launch#2x.png at 640x960.
After trying some of the answers in this post, I consulted with Louie Mantia (former Apple, Square, and Iconfactory designer) and all the answers so far on this post are wrong (or at least incomplete). Apple starts with the 57px icon and a radius of 10 then scales up or down from there. Thus you can calculate the radius for any icon size using 10/57 x new size (for example 10/57 x 114 gives 20, which is the proper radius for a 114px icon). Here is a list of the most commonly used icons, proper naming conventions, pixel dimensions, and corner radii.
Icon1024.png - 1024px - 179.649
Icon512.png - 512px - 89.825
Icon.png - 57px - 10
Icon#2x.png - 114px - 20
Icon-72.png - 72px - 12.632
Icon-72#2x.png - 144px - 25.263
Icon-Small.png - 29px - 5.088
Icon-Small#2x.png - 58px - 10.175
Also, as mentioned in other answers, you don't actually want to crop any of the images you use in the binary or submit to Apple. Those should all be square and not have any transparency. Apple will automatically mask each icon in the appropriate context.
Knowing the above is important, however, for icon usage within app UI where you have to apply the mask in code, or pre-rendered in photoshop. It's also helpful when creating artwork for websites and other promotional material.
Additional reading:
Neven Mrgan on additional icon sizes and other design considerations: ios app icon sizes
Bjango's Marc Edwards on the different options for creating roundrects in Photoshop and why it matters: roundrect
Apple's official docs on icon size and design considerations: Icons and Images
Update:
I did some tests in Photoshop CS6 and it seems as though 3 digits after the decimal point is enough precision to end up with the exact same vector (at least as displayed by Photoshop at 3200% zoom). The Round Rect Tool sometimes rounds the input to the nearest whole number, but you can see a significant difference between 90 and 89.825. And several times the Round Rectangle Tool didn't round up and actually showed multiple digits after the decimal point. Not sure what's going on there, but it's definitely using and storing the more precise number that was entered.
Anyhow, I've updated the list above to include just 3 digits after the decimal point (before there were 13!). In most situations it would probably be hard to tell the difference between a transparent 512px icon masked at a 90px radius and one masked at 89.825, but the antialiasing of the rounded corner would definitely end up slightly different and would likely be visible in certain circumstances especially if a second, more precise mask is applied by Apple, in code, or otherwise.
I see a lot of "px" discussion but no one is talking percentages which is the fixed number you want to calculate by.
22.37% is the key percentage here. Multiply any of the image sizes mentioned above in by 0.2237 and you will get the correct pixel radius for that size.
Before iOS 8, Apple used less rounding, using 15.625%.
EDIT: Thanks #Chris Prince for commenting with the iOS 8/9/10 radius percentage: 22.37%
Important: iOS 7 icon equation
With the upcoming release of iOS 7 you will notice that the "standard" icon radius has been increased. So try to do what Apple and I suggested with this answer.
It appears that for a 120px icon the formula that best represents its shape on iOS 7 is the following superellipse:
|x/120|^5 + |y/120|^5 = 1
Obviously you can change the 120 number with the desired icon size to get the corresponding function.
Original
You should provide an image that has 90° corners (it’s important to
avoid cropping the corners of your icon—iOS does that for you when it
applies the corner-rounding mask)
(Apple Documentation)
The best approach is not rounding the corners of your icons at all. If you set your icon as a square icon, iOS will automatically overlay the icon with a predefined mask that will set the appropriate rounded corners.
If you manually set rounded corners for your icons, they will probably look broken in this or that device, because the rounding mask happens to slightly change from an iOS version to another. Sometimes your icons will be slightly larger, sometimes (sigh) slightly smaller. Using a square icon will free you from this burden, and you will be sure to have an always up-to-date and good looking icon for your app.
This approach is valid for each icon size (iPhone/iPod/iPad/retina), and also for the iTunes artwork. I followed this approach a couple of times, and if you want I can post you a link to an app that uses native square icons.
Edit
To better understand this answer, please refer to the official Apple documentation about iOS icons. In this page it is clearly stated that a square icon will automatically get these things when displayed on an iOS device:
Rounded corners
Drop shadow
Reflective shine (unless you prevent the shine effect)
So, you can achieve whatever effect you want just drawing a plain square icon and filling content in it. The final corner radius will be something similar to what the other answers here are saying, but this will never be guaranteed, since those numbers are not part of the official Apple documentation on iOS. They ask you to draw square icons, so ... why not?
People arguing about the corner radius being slightly increased but actually that's not the case.
From this blog:
A ‘secret’ of Apple’s physical products is that they avoid tangency (where a radius meets a line at a single point) and craft their surfaces with what’s called curvature continuity.
You don't need to apply corner radius to icons for iOS. Just provide square icons. But if you still want to know how, the actual shape is called Squircle and below is the formula:
The answer from dbarnard has the formula to calculate the correct radius, but since you were looking for the templates, all the masks and overlays can be found in this directory:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/PrivateFrameworks/MobileIcons.framework
(path is for recent versions of XCode. For older version it will probably be inside /Developer/).
As others have noted, you should NOT mask them yourself, but you can use these to check how your icons will look once masked.
(credits for this finding goes to Neven Mrgan IIRC)
The corner radius of the 57 x 57 pixel icon is 9 pixels.
As others have said, you don't want to round your corners. You want to ship flat (no layers or alpha) square graphics. Apple changed the mask they use for rounding your corners in iOS7 and then again in iOS8. You can find these masks inside your Xcode application bundle. The path changes with every new SDK version they release. So, I'll show you how you can always find it.
find /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs -name 'MobileIcons.framework'
At this very moment, the path found by that command is /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/MobileIcons.framework but don't trust that. Use the command to find it yourself.
That path points to a directory with these files (again, at the time of this post)
./AppFolderBadgeIconMask-128_1only_.png
./AppFolderBadgeIconMask-16_1only_.png
./AppFolderBadgeIconMask-256_1only_.png
./AppFolderBadgeIconMask-32_1only_.png
./AppFolderBadgeIconMask-512_1only_.png
./AppFolderBadgeIconOverlay-128_1only_.png
./AppFolderBadgeIconOverlay-16_1only_.png
./AppFolderBadgeIconOverlay-256_1only_.png
./AppFolderBadgeIconOverlay-32_1only_.png
./AppFolderBadgeIconOverlay-512_1only_.png
./AppFolderBadgeIconShadow-128_1only_.png
./AppFolderBadgeIconShadow-16_1only_.png
./AppFolderBadgeIconShadow-256_1only_.png
./AppFolderBadgeIconShadow-32_1only_.png
./AppFolderBadgeIconShadow-512_1only_.png
./AppIconMask#2x~ipad.png
./AppIconMask#2x~iphone.png
./AppIconMask#3x~iphone.png
./AppIconMask~ipad.png
./AppIconMask~iphone.png
./CarAppIconMask.png
./CarNotificationAppIconMask.png
./DefaultIcon-20.png
./DefaultIcon-20#2x.png
./DefaultIcon-20#3x.png
./DefaultIcon-29.png
./DefaultIcon-29#2x.png
./DefaultIcon-29#3x.png
./DefaultIcon-40.png
./DefaultIcon-40#2x.png
./DefaultIcon-40#3x.png
./DefaultIcon-60#2x~iphone.png
./DefaultIcon-60#3x~iphone.png
./DefaultIcon-76#2x~ipad.png
./DefaultIcon-76~ipad.png
./DocumentBadgeMask-145.png
./DocumentBadgeMask-145#2x.png
./DocumentBadgeMask-20.png
./DocumentBadgeMask-20#2x.png
./DocumentBadgeMask-20#3x.png
./DocumentBase-320#2x~ipad.png
./DocumentBase-320~ipad.png
./DocumentBase-48.png
./DocumentBase-48#2x.png
./DocumentBase-48#3x.png
./DocumentMask-320#2x~ipad.png
./DocumentMask-320~ipad.png
./DocumentMask-48.png
./DocumentMask-48#2x.png
./DocumentMask-48#3x.png
./NanoDefaultIcon-24.0#2x.png
./NanoDefaultIcon-27.5#2x.png
./NanoDefaultIcon-40.0#2x.png
./NanoDefaultIcon-44.0#2x.png
./NanoDefaultIcon-86.0#2x.png
./NanoDefaultIcon-98.0#2x.png
./NanoIconMaskChiclet-24.0#2x.png
./NanoIconMaskChiclet-27.5#2x.png
./NanoIconMaskChiclet-40.0#2x.png
./NanoIconMaskChiclet-44.0#2x.png
./NanoIconMaskChiclet-86.0#2x.png
./NanoIconMaskChiclet-98.0#2x.png
./NewsstandDefaultMagazine_1only_.png
./NewsstandDefaultNewspaper_1only_.png
./NewsstandMagazineGradientLeft#2x~ipad.png
./NewsstandMagazineGradientLeft#2x~iphone.png
./NewsstandMagazineGradientLeft~ipad.png
./NewsstandMagazineGradientLeft~iphone.png
./NewsstandMagazineGradientRight#2x~ipad.png
./NewsstandMagazineGradientRight#2x~iphone.png
./NewsstandMagazineGradientRight~ipad.png
./NewsstandMagazineGradientRight~iphone.png
./NewsstandMagazineSwitcherGradientLeft.png
./NewsstandMagazineSwitcherGradientLeft#2x.png
./NewsstandNewspaperGradientBottom#2x~ipad.png
./NewsstandNewspaperGradientBottom#2x~iphone.png
./NewsstandNewspaperGradientBottom~ipad.png
./NewsstandNewspaperGradientBottom~iphone.png
./NewsstandNewspaperGradientLeft#2x~ipad.png
./NewsstandNewspaperGradientLeft#2x~iphone.png
./NewsstandNewspaperGradientLeft~ipad.png
./NewsstandNewspaperGradientLeft~iphone.png
./NewsstandNewspaperGradientRight#2x~ipad.png
./NewsstandNewspaperGradientRight#2x~iphone.png
./NewsstandNewspaperGradientRight~ipad.png
./NewsstandNewspaperGradientRight~iphone.png
./NewsstandNewspaperSwitcherGradientBottom.png
./NewsstandNewspaperSwitcherGradientBottom#2x.png
./NewsstandNewspaperSwitcherGradientLeft.png
./NewsstandNewspaperSwitcherGradientLeft#2x.png
./NewsstandNewspaperSwitcherGradientRight.png
./NewsstandNewspaperSwitcherGradientRight#2x.png
./NewsstandThumbnailShadow#2x~ipad.png
./NewsstandThumbnailShadow#2x~iphone.png
./NewsstandThumbnailShadow~ipad.png
./NewsstandThumbnailShadow~iphone.png
./NotificationAppIconMask.png
./NotificationAppIconMask#2x.png
./NotificationAppIconMask#3x.png
./SpotlightAppIconMask.png
./SpotlightAppIconMask#2x.png
./SpotlightAppIconMask#3x.png
./TableIconMask.png
./TableIconMask#2x.png
./TableIconMask#3x.png
./TableIconOutline.png
./TableIconOutline#2x.png
./TableIconOutline#3x.png
As you can see, there are a lot of different masks, but they are named pretty clearly. Here is the AppIconMask#3x~iphone.png image:
You can use that to test your icon to see if it will look okay after it is masked. But, don't round your corners. If you do, when Apple changes those masks again, you will have artifacts.
All the previous answers to this question are now out of date. Since at least May 2015, Apple requires you to provide square icons with no rounding:
Keep icon corners square. The system applies a mask that rounds icon corners automatically.
https://developer.apple.com/ios/human-interface-guidelines/graphics/app-icon/
If not considering stroke, the exact radius is actually 10px for 57x57 icon.
I get this info from iconreference.
Update (as of Jan. 2018) for App Icon requirements:
https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/app-icon/
Keep icon corners square. The system applies a mask that rounds icon corners automatically.
Keep the background simple and avoid transparency. Make sure your icon is opaque, and don’t clutter the background. Give it a simple background so it doesn’t overpower other app icons nearby. You don’t need to fill the entire icon with content.
The iphone rounds corners for you, all you need is a square 57x57 png icon and u should be good
When designing my app icons with Photoshop, I have found that no integer corner radius fits the device's mask exactly.
What I do now is create an empty project with Xcode, set a completely white PNG file as the icon, and turn off the preset bevel & gloss. Then, I run the app and take a screenshot of the home screen. Now, you can easily create a mask from that image, which you can use in Photoshop. This will get you perfectly rounded corners.
There are two totally conflicting answers with large number of votes one is 160px#1024 the other is 180px#1024. So witch one?
I ran some experiments and I think that it is 180px#1024 so drbarnard is correct.
I downloaded iTunes U icon from the App Store it's 175x175px I upscaled it in photoshop to 1024px and put two shapes on it, one with 160px radius and one with 180px.
As you can see below the shape (thin gray line) with 160px (the 1st one) is a bit off whereas the one with 180px looks just fine.
This is what I do now in PhotoShop:
I create a canvas sized 1026x1026px with a 180px mask for main
design Smart Object.
I duplicate the main Smart Object 5 times and resize them to 1024px, 144px, 114px, 72px and 57px.
I put a "New layered Based Slice" on each Smart Objects and I rename slices according to their size (e.g. icon-72px).
When I save the artwork I select "All User Slices" and BANG! I have
all icons necessary for my app.
I tried 228px radius for 1024x1024 and it worked :)
You don't need to apply corner radius to your app icon, you can just apply square icons. The device is automatically applying corner radius.
WWDC 2022 brought good news!
Now, Xcode 14 automatically generates all the required app icon sizes based on a single input icon 1024x1024 pix (Single Size). However, if you need an old-school approach, choose All Sizes from dropdown menu.
So, all you have to know now is the radius of input icon which is 180 px.

Generating icons for iPhone UITabBar

I’ve been busy working on the graphics for my iPhone application. I started working on generating icons for my UITabBar and ran into lots of problems. How do you create these icons?
I created this solution:
http://www.nailrails.com/?p=46
Are there any shortcomings to this approach? It seemed to work for the few icons I created...
Apple's guidelines can be found at http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW1
The docs are pretty straightforward-- alpha is all that matters when the image gets loaded by the toolbar, meaning that anything that's not at least semitransparent will render in the same opaque shade. As for how I do that, I mainly use Adobe tools. Fireworks is my preferred tool but Photoshop's also more than up to it. Another one I've had good results with is Acorn, which is frankly a lot cheaper while being more than sophisticated enough for this kind of work. I'm not really a graphic designer but a certain familiarity with this kind of stuff goes with the job.
I have an article up on my site that shows how to use OmniGraffle with a template I use to create great iPhone toolbar icons in minutes:
http://steveweller.com/articles/toolbar-icons/
The template sets up a grid to work to that corresponds to one square for each pixel. You draw your icon in white on top of the black template background and then export as a PDF exactly the right area to match the icon size you need (typically 21 pixels high). Then you reimport the PDF, resize it to the final icon size (21 pixels again), and export as PNG. The template does nothing magical; it just provides an already set up working area and helps you get the final PNG right every time to the scale is correct.
You could use the same technique in Acorn or any other app that supports PDF export and layers.
(I use Gimp. Assume your icon layer already has alpha channel.)
Right click the layer, then add layer mask.
Done with option "transfer alpha channel of layer" chosen.
Select the whole layer (but not layer mask), and clear it with pure white.
Resize image to Apple-suggested size, and export it as png file.
You may also paint directly on the layer mask.