Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5520417
  • 博文数量: 763
  • 博客积分: 12108
  • 博客等级: 上将
  • 技术积分: 15717
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-28 21:21
个人简介

业精于勤,荒于嬉

文章分类

全部博文(763)

文章存档

2018年(6)

2017年(15)

2016年(2)

2015年(31)

2014年(14)

2013年(87)

2012年(75)

2011年(94)

2010年(190)

2009年(38)

2008年(183)

2007年(28)

分类:

2010-09-24 11:25:07

Application Icons

Every application must specify an icon to be displayed on the device’s Home screen and in the App Store. And an application may specify several different icons for use in different situations. For example, applications can provide a small version of the application icon to use when displaying search results.

To specify the icons for your application, add the CFBundleIconFiles key to your application’s Info.plist file and list the icon image filenames in the associated array. The filenames can be anything you want but all image files must be in the PNG format and reside in the top-level of your application bundle. When the system needs an appropriately sized icon, it looks at the files in the CFBundleIconFiles array and picks the one whose size most closely matches the intended usage. (If your application also runs in iOS 3.1.3 or earlier, you must use specific names for your icon image files; these filenames are described later in this section.)

Table 7-3 lists the dimensions of the image files you can associate with the CFBundleIconFiles key, along with basic information about the intended usage for each icon. For devices that support high-resolution versions of an icon, two icons should be provided with the second one being a high-resolution version of the original. The names of the two icons should be the same except for the inclusion of the string @2x in the filename of the high-resolution image as described in “Updating Your Image Resource Files.” For detailed information about the usage and preparation of your icons, see iPhone Human Interface Guidelines or iPad Human Interface Guidelines.

Table 7-3  Sizes for images in the CFBundleIconFiles key

Icon

Idiom

Size

Usage

Application icon (required)

iPhone

57 x 57 pixels

114 x 114 pixels (@2x)

This is the main icon for applications running on iPhone and iPod touch. The@2x variant of the icon is for use on iPhone 4 devices only.

Application icon (required)

iPad

72 x 72 pixels

This is the main icon for applications running on iPad.

Settings/Search results icon

iPhone/iPad

29 x 29 pixels

58 x 58 pixels (@2x)

Displayed in conjunction with search results on iPhone and iPod touch. Also used by the Settings application on all device types.

(The @2x variant of the icon is for use on iPhone 4 devices only and is not supported on iPad.)

Search results icon

iPad

50 x 50 pixels

Displayed in conjunction with search results on iPad.

When specifying icon files using the CFBundleIconFiles key, it is best to omit the filename extensions of your image files. If you include a filename extension, you must explicitly add all of your image files (including any high-resolution variants) to the array. When you omit the filename extension, the system automatically detects high-resolution variants of your file using the base filename you provide.

Note: Do not confuse the CFBundleIconFiles key with the CFBundleIconFile key. The keys provide similar behaviors but the plural version is preferred because it allows you to specify an array of image filenames instead of a single filename. The plural version of the key is available only in iOS 3.2 and later.

If your iPhone application supports running in iOS 3.1.3 or earlier, you must use specific naming conventions when creating your icon image files. Because the CFBundleIconFiles key was introduced in iOS 3.2, it is not recognized by earlier versions of the system. Instead, earlier versions of the system look for application icons by name. The sizes of the icons are the same as those listed in Table 7-3, but each icon must be named as follows:

  • Icon.png - The name for the application icon on iPhone or iPod touch.

  • Icon-72.png - The name for the application icon on iPad.

  • Icon-Small.png - The name for the search results icon on iPhone and iPod touch. This file is also used for the Settings icon on all devices.

  • Icon-Small-50.png - The name of the search results icon on iPad.

Important: The use of fixed filenames for your application icons is for compatibility with earlier versions of iOS only. Even if you use these fixed icon filenames, your application should continue to include the CFBundleIconFiles key in itsInfo.plist if it is able to run in iOS 3.2 and later. In iOS 3.2 and earlier, the system looks for icons with the fixed filenames first. In iOS 4 and later, the system looks for icons in the CFBundleIconFiles key first.

In addition to the other icon files, developers who distribute their applications using ad hoc distribution must include a 512 x 512 version of their icon and give it the name iTunesArtwork (no filename extension). This icon is displayed by iTunes when presenting your application for distribution. Like all other icon files, the iTunesArtwork image file must reside at the top-level of your application bundle. The file should be the same one you would have submitted to the App Store (typically a JPEG or PNG file), were you to distribute your application that way.

For more information about the CFBundleIconFiles key, see Information Property List Key Reference. For information about creating your application icons, see iPhone Human Interface Guidelines and iPad Human Interface Guidelines.

Application Launch Images

When it launches an application, the system temporarily displays a static launch image on the screen. The launch image is an image file that you provide and is usually a prerendered version of your application’s default user interface. Presenting this image gives the user immediate feedback that the application launched and also gives your application time to initialize itself and prepare its initial set of views for display. Once your application is ready to run, the image is removed and the corresponding windows and views are shown.

Every application must provide at least one launch image. This is typically a file named Default.png that displays your application’s initial screen in a portrait orientation. However, you can also provide other launch images to be used under different launch conditions. Launch images must be PNG files and must reside in the top level of your application’s bundle directory. The name of each launch image indicates when it is to be used, and the basic format for launch image filenames is as follows:

.png

The  portion of the filename is either the string Default or the custom string associated with theUILaunchImageFile key in your application’s Info.plist file. The  portion is the optional string @2x and should be included only on images intended for use on high-resolution screens. Other optional modifiers may also be included in the name, and several standard modifiers are discussed in the sections that follow.

Table 7-4 lists the typical dimensions for launch images in iOS applications. For all dimensions, the image width is listed first, followed by the image height. For precise information about which size launch image to use, and how to prepare your launch images, see iPhone Human Interface Guidelines or iPad Human Interface Guidelines.

Table 7-4  Typical launch image dimensions

Device

Portrait

Landscape

iPhone and iPod touch

320 x 480 pixels

640 x 960 pixels (high resolution)

Not supported

iPad

768 x 1004 pixels

1024 x 748 pixels

To demonstrate the naming conventions, suppose your iOS application’s Info.plist file included the UILaunchImageFilekey with the value MyLaunchImage. The standard resolution version of the launch image would be namedMyLaunchImage.png and would be in a portrait orientation (480 x 320). The high-resolution version of the same launch image would be named MyLaunchImage@2x.png. If you did not specify a custom launch image name these files would need to be named Default.png and Default@2x.png respectively.


Providing Launch Images for Different Orientations

In iOS 3.2 and later, an iPad application can provide different launch images depending on whether the device is in a portrait or landscape configuration. To specify a launch image for a different orientation, you must add a special modifier string to the base file name of your standard launch image. Thus, the format of each file name becomes the following:

.png

Table 7-5 lists the possible modifiers you can specify for the  value in your image filenames. As with any launch image, the file must be in the PNG format. These modifiers are supported for launch images used in iPad applications only; they are not supported for applications running on iPhone or iPod touch devices.

Table 7-5  Launch image orientation modifiers

Modifier

Description

-PortraitUpsideDown

Specifies an upside-down portrait version of the launch image. A file with this modifier takes precedence over a file with the -Portrait modifier for this specific orientation.

-LandscapeLeft

Specifies a left-oriented landscape version of the launch image. A file with this modifier takes precedence over a file with the -Landscape modifier for this specific orientation.

-LandscapeRight

Specifies a right-oriented landscape version of the launch image. A file with this modifier takes precedence over a file with the -Landscape modifier for this specific orientation.

-Portrait

Specifies the generic portrait version of the launch image. This image is used for right side-up portrait orientations and takes precedence over the Default.png image file (or your custom-named replacement for that file). If a file with the -PortraitUpsideDown modifier is not specified, this file is also used for upside-down portrait orientations as well.

-Landscape

Specifies the generic landscape version of the launch image. If a file with the -LandscapeLeft or-LandscapeRight modifier is not specified, this image is used instead. This image takes precedence over the Default.png image file (or your custom-named replacement for that file).

None

If you provide a launch image file with no orientation modifier, that file is used when no other orientation-specific launch image is available. In iOS 3.1.x and earlier, this is the only supported launch image file type and must be named Default.png.

For example, if you specify the value MyLaunchImage in the UILaunchImageFile key, the custom landscape and portrait launch images for your application would be named MyLaunchImage-Landscape.png and MyLaunchImage-Portrait.png. (The high-resolution variants of your images would be MyLaunchImage-Landscape@2x.png and MyLaunchImage-Portrait@2x.png.) If you did not specify a custom launch image filename, you would use the names Default-Landscape.png and Default-Portrait.png.

No matter which launch image is selected by the system, your application always launches in a portrait orientation initially and then rotates as needed to the correct orientation. Therefore, your application:didFinishLaunchingWithOptions: method should always assume a portrait orientation when setting up your window and views. Shortly after yourapplication:didFinishLaunchingWithOptions: method returns, the system sends any necessary orientation-change notifications to your application’s window, giving it and your application’s view controllers a chance to reorient any views using the standard process. For more information about how your view controllers manage the rotation process, see “Custom View Controllers” in View Controller Programming Guide for iOS.

Providing Device-Specific Launch Images

It is possible to mark specific image files as usable only on a specific type of device. This capability simplifies the code you have to write for Universal applications. Rather than creating separate code paths to load one version of a resource file for iPhone and a different version of the file for iPad, you can let the bundle-loading routines choose the correct file at load time. All you have to do is specify one of the following values for the  portion of your image’s filename:

  • ~ipad - The resource should be loaded on iPad devices only.

  • ~iphone - The resource should be loaded on iPhone or iPod touch devices only.

For example, if the name of your application’s launch image on iPhone and iPod touch is MyLaunchImage.png, the iPad specific version would be MyLaunchImage~ipad.png. Although you could include a MyLaunchImage~iphone.png image for the iPhone specific version (and a MyLaunchImage@2x~iphone.png for the high-resolution variant), it is better to use device modifiers only when necessary to distinguish the image from the default version. If no device-specific version of an image is present, the system loads the default version automatically.

Note: Another way to specify device-specific launch images is using device-specific keys in your Info.plist file. Adding a device-specific modifier to the UILaunchImageFile key lets you specify a custom basename for launch images used on different devices. For more information on how to apply device modifiers to keys in the Info.plist file, see Information Property List Key Reference.

Providing Launch Images for Custom URL Schemes

If your application supports a custom URL scheme, the system can display a custom launch image whenever it launches your application in response to a URL request. Prior to opening your application, the system looks for a launch image whose filename matches the following format:

-.png

The  modifier is a string representing the name of your URL scheme name. For example, if your application supports a URL scheme with the name myscheme, then the system would look for an image with the name Default-myscheme.png (or Default-myscheme@2x.png in the high-resolution case) in the application’s bundle. If the application’sInfo.plist file includes the UILaunchImageFile key, then the base name portion changes from Default to the custom string you provide in that key.

Note: You can combine a URL scheme modifier with orientation modifiers. If you do this, the format for the file name is--.png. For more information about the launch orientation modifiers, see “Providing Launch Images for Different Orientations.”

In addition to including the launch images at the top level of your bundle, you can also include localized versions of that images in your application’s language-specific project subdirectories. For more information on localizing resources in your application, see “Internationalizing Your Application.”


阅读(2454) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~