首页 > 代码库 > [Documentation]UIImageView官方文档中文翻译
[Documentation]UIImageView官方文档中文翻译
An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the UIImageView
class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.
UIImageView
object displays one of its images, the actual behavior is based on the properties of the image and the view. If either of the image’s leftCapWidth
or topCapHeight
properties are non-zero, then the image is stretched according to the values in those properties. Otherwise, the image is scaled, sized to fit, or positioned in the image view according to the contentMode
property of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.topCapHeight 属性都为非零,那么图像会根据属性中的值被拉伸。否则,图像根据视图的Contentmode属性会成比例地调整大小以适应或者定位于图像视图中。使用同样大小的图像是被非常推荐的(但不是必须的)。如果图像是不同大小的,每幅图像都会被调整来适应各自的模式(PS:模式指的是contentMode)
NSData
object containing either a PNG or JPEG representation of the image data using the UIImagePNGRepresentation
and UIImageJPEGRepresentation
functions.UIImageJPEGRepresentation
函数获得一个包含PNG图像或者JPEG图像描述数据的NSData对象。The system uses image objects to represent still pictures taken with the camera on supported devices. To take a picture, use the UIImagePickerController
class. To save a picture to the Saved Photos album, use the UIImageWriteToSavedPhotosAlbum
function.
系统使用 图像对象 来描述(存储)可支持的设备的相机拍摄的静态图像。如果是想拍照片,使用UIImagePickerController 类。如果是要保存图片到已存储的照片集中,使用UIImageWriteToSavedPhotosAlbum 类。
Images and Memory Management
图像和内存管理
In low-memory situations, image data may be purged from a UIImage
object to free up memory on the system. This purging behavior affects only the image data stored internally by the UIImage
object and not the object itself. When you attempt to draw an image whose data has been purged, the image object automatically reloads the data from its original file. This extra load step, however, may incur a small performance penalty.
在低内存的情况下,图像数据可能会被从UIImage对象清除来释放系统的内存。这个清除动作仅仅会影响由UIImage对象内部存储的图像数据而不会影响图像对象本身。当你尝试显示一副数据已经被清除的图像,图像对象会自动地从原文件重新载入数据。这个额外的载人呀步骤可能会引起小小的运行问题。(PS:也就是说 内存不够的时候就会清除UIImage对象的数据来是释放内存,要用到图像的时候就重新载入图像)
You should avoid creating UIImage
objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.
避免创建大于1024 x 1024的UIImage对象。这种大图像不仅会消耗的大量内存,当使用这种图像作为OpenGL ES的材质或者在视图或者图层上显示这种图像,可能会遇到问题。当执行基于代码的操作时这种图像大小限制是不适用的,比如通过支持位图的图形环境来改变一副大于1024 x 1024像素的图像的大小。事情上,你可能需要用这种方法来改变图像的大小(或者把图像分割成几个更小的图像)以在你的视图上显示图像。
Comparing Images in iOS 8
对比iOS 8 中的图像处理
The bulk of what an image is lies in its CGImageRef
and not in the UIImage
object it is wrapped in. As of iOS 8, you can no longer rely on pointer equality to compare cached UIImage objects as the caching mechanism may not return the same UIImage
object, but will have cached image data separately. You must use isEqual:
to correctly test for equality.
图像的大部分数据存储在它的 CGImageRef 中,而不是包入UIImage对象中。 在iOS 8 中,你不可以再依靠指针相同去比较已缓冲的UIImage对象因为缓冲机制可能不会返回同一个UIImage对象,而是分离地缓存图像数据。一定要使用isEqual:来正确测试相等与否。(PS:我不了解这块内容 翻错了别打我?? 不过好像我什么都不怎么了解啊 你们自己看吧 大部分都不会有错的 )
Image Assets and Trait Collections
You can assign an image to a UIImageAsset
object through the use of trait collections. Registering an image to an image asset provides a way to group images together. Through the use of trait collections, you can retrieve an image that best fits your current layout. For example, you can retrieve a different image depending on whether your view has a compact or regular size class.
你可以通过使用trait colloections分配图像给UIImageAsset对象。分配一副图片给到一个图片集(??PS:不知道大家怎么叫它们的我就随便叫了,大家意会一下)提供了一种分类图像的方法。通过trait collections,你可以获取最适配你当前布局的图像。比如,你可以取得一副取决于你的视图是紧凑还是常规大小的不同的图像。
Supported Image Formats
支持的文件格式
Table 1 lists the file formats that can be read by the UIImage
class.
表1是可以被UIImage类读取的文件格式表。
Format | Filename extensions |
---|---|
Tagged Image File Format (TIFF) |
|
Joint Photographic Experts Group (JPEG) |
|
Graphic Interchange Format (GIF) |
|
Portable Network Graphic (PNG) |
|
Windows Bitmap Format (DIB) |
|
Windows Icon Format |
|
Windows Cursor |
|
X Window System bitmap |
|
Note:Windows Bitmap Format (BMP) files that are formatted as RGB-565 are converted to ARGB-1555 when they are loaded.
注意:RGB-565的 BMP文件在载入时会被转换成ARGB-1555。
纯原创 转载请注明!
[Documentation]UIImageView官方文档中文翻译