IT English Collection(31)of About Drawing and Printing in iOS

1 前言

  从本节开始我们开始学习绘图相应技术,本节主要简单的介绍了IOS中的绘图和打印技术,用到的技术和如何进行。

  转载请注明出处:http://blog.csdn.net/developer_zhang

2 详述

2.1 原文

This document covers three relatedsubjects:


  Drawing custom UI views. Custom UI views allow you to draw content that cannot easily be drawn with standard UI elements. For example, a drawing program might use a custom view for the user’s drawing, or anarcade game might use a custom view into which it drawssprites.
  Drawing into offscreen bitmap and PDF content. Whether you plan to display the images later, export them to a file, or print the images to an AirPrint-enabled printer, offscreen drawing lets you do so withoutinterrupting the user’s workflow.
  Adding AirPrint support to your app. The iOS printing system lets you draw your content differently to fit on the page.
Figure I-1  You can combine custom views with standard views, and even draw things offscreen.


At a Glance

  The iOS native graphics system combines three major technologies: UIKit, Core Graphics, and Core Animation. UIKit provides views and some high-level drawing functionality within those views, Core Graphics providesadditional (lower-level) drawing support within UIKit views, and Core Animation provides the ability to applytransformations and animation to UIKit views. Core Animation is also responsible for viewcompositing.

Custom UI Views Allow Greater Drawing Flexibility


  This document describes how to draw into custom UI views using native drawing technologies. These technologies, which include the Core Graphics and UIKit frameworks, support 2D drawing.

  Before you consider using a custom UI view, you should make certain that you really need to do so. Native drawing issuitable for handling more complex 2D layout needs. However, because custom views areprocessor-intensive, you should limit the amount of drawing you do using native drawing technologies.

  As an alternative to custom drawing, an iOS app can draw things onscreen in several other ways.

Using standard (built-in) views. Standard views let you draw common user-interfaceprimitives, including lists, collections, alerts, images, progress bars, tables, and so on without the need toexplicitly draw anything yourself. Using built-in views not onlyensures a consistent user experience between iOS apps, but also saves you programmingeffort. If built-in views meet your needs, you should read View Programming Guide for iOS.
Using Core Animation layers. Core Animation lets you create complex, layered 2D views with animation and transformations. Core Animation is a good choice foranimating standard views, or for combining views in complex ways to present theillusion of depth, and can be combined with custom-drawn views as described in this document. To learn more about Core Animation, read Core Animation Overview.
Using OpenGL ES in a GLKit view or a custom view. The OpenGL ES framework provides a set of open-standard graphics libraries gearedprimarily toward game development or apps that require high framerates, such as virtualprototyping apps and mechanical and architectural design apps. It conforms to the OpenGL ES 2.0 and OpenGL ES v1.1specifications. To learn more about OpenGL drawing, read OpenGL ES Programming Guide for iOS.
Using web content. The UIWebView class lets you display web-based user interfaces in an iOS app. To learn more about displaying web content in a web view, read Using UIWebView to display select document types and UIWebView Class Reference.
Depending on the type of app you are creating, it may be possible to use little or no custom drawing code. Althoughimmersive apps typically make extensive use of custom drawing code, utility andproductivity apps can often use standard views and controls to display their content.

The use of custom drawing code should be limited to situations where the content you display needs to changedynamically. For example, a drawing app typically needs to use custom drawing code totrack the user’s drawing commands, and an arcade-style game may need to update the screenconstantly to reflect the changing game environment. In those situations, you should choose anappropriate drawing technology and create a custom view class to handle events and update the displayappropriately.

On the other hand, if the bulk of your app’s interface isfixed, you can render the interfacein advance to one or more image files and display those images at runtime using the UIImageView class. You can layer image views with other content as needed to build your interface. You can also use the UILabel class to display configurable text and include buttons or other controls to provide interactivity. For example, an electronic version of aboard game can often be created with little or no custom drawing code.

  Because custom views are generally more processor-intensive (with less help from the GPU), if you can do what you need to do using standard views, you should always do so. Also, you should make your custom views as small as possible, containing only content that you cannot draw in any other way, use use standard views for everything else. If you need to combine standard UI elements with custom drawing, consider using a Core Animation layer tosuperimpose a custom view with a standard view so that you draw as little as possible.

A Few Key Concepts Underpin Drawing With the Native Technologies

  When you draw content with UIKit and Core Graphics, you should be familiar with a few concepts in addition to the view drawing cycle.

  For the drawRect: method, UIKit creates a graphics context for rendering to the display. This graphics context contains the information the drawing system needs toperform drawing commands, including attributes such as fill andstroke color, the font, the clipping area, and line width. You can also create and draw into custom graphics context for bitmap images and PDF content.
  UIKit has a default coordinate system where the origin of drawing is at the top-left of a view;positive values extend downward and to the right of that origin. You can change the size, orientation, and position of the default coordinate system relative to theunderlying view or window by modifying the current transformationmatrix, which maps a view’s coordinate space to the device screen.
  In iOS, the logical coordinate space, which measures distances in points, is not equal to the device coordinate space, which measures inpixels. For greater precision, points are expressed in floating-point values.
Relevant Chapter: “iOS Drawing Concepts”
UIKit, Core Graphics, and Core Animation Give Your App Many Tools For Drawing

The UIKit and Core Graphics have many complementary graphics capabilities thatencompass graphics contexts, Bézier paths, images, bitmaps, transparency layers, colors, fonts, PDF content, and drawing rectangles and clipping areas. In addition, Core Graphics has functions related to line attributes, color spaces, pattern colors,gradients, shadings, and image masks. The Core Animation framework enables you to create fluid animations by manipulating and displaying content created with other technologies.

Relevant Chapters: “iOS Drawing Concepts,” “Drawing Shapes Using Bézier Paths,” “Drawing and Creating Images,” “Generating PDF Content”
Apps Can Draw Into Offscreen Bitmaps or PDFs
It is often useful for an app to draw content offscreen:

Offscreen bitmap contexts are often used when scaling down  photographs for upload, rendering content into an image file forstorage purposes, or using Core Graphics to generate complex images for display.
Offscreen PDF contexts are often used when drawing user-generated content for printing purposes.
  After you create an offscreen context, you can draw into it just as you would draw within the drawRect: method of a custom view.

Relevant Chapters: “Drawing and Creating Images,” “Generating PDF Content”


Apps Have a Range of Options for Printing Content


  As of iOS 4.2, apps can print content wirelessly to supported printers using AirPrint. Whenassembling a print job, they have three ways to give UIKit the content to print:

  They can give the framework one or more objects that are directly printable; such objects requireminimal app involvement. These are instances of the NSData, NSURL, UIImage, or ALAsset classes containing or referencing image data or PDF content.
  They can assign a print formatter to the print job. A print formatter is an object that can lay out content of a certain type (such as plain text or HTML) over multiple pages.
  They can assign a page renderer to the print job. A page renderer is usually an instance of a custom subclass of UIPrintPageRenderer that draws the content to be printed in part or in full. A page renderer can use one or more print formatters to help it draw and format its printable content.


Relevant Chapter: “Printing”


It’s Easy to Update Your App for High-Resolution Screens


  Some iOS devices feature high-resolution screens, so your app must be prepared to run on these devices and on devices with lower-resolution screens. iOS handles much of the work required to handle the different resolutions, but your app must do therest. Your tasks include providing specially named high-resolution images and modifying your layer- and image-related code to take the currentscale factor into account.

Relevant Appendix: “Supporting High-Resolution Screens In Views”

2.2 生词

subjects['sʌbdʒekts; 'sʌbdʒɪkts]n. 学科;科目(subject的复数);[图情] 主题;被试者

arcade[ɑː'keɪd]n. 拱廊;(内设投角子电子游戏机等的)游乐场;有拱廊的街道

sprite[spraɪt]n. 妖精,精灵;鬼怪;调皮鬼

offscreen['ɔfskri:n, 'ɔ:-]adv. 幕后;私生活方面

bitmap['bɪtmæp]n. [计] 位图,位映像

AirPrint 无线打印

interrupt[,intə'rʌpt]n. 中断

figure['fɪgə]n. 数字;人物;图形;价格;(人的)体形;画像

additional[ə'dɪʃ(ə)n(ə)l]adj. 附加的,额外的

transformation[trænsfə'meɪʃ(ə)n; trɑːns-; -nz-]n. []转化;转换;改革;变形

compositing[kəm'pəuzitiŋ]vt. 使合成;使混合(composite的ing形式)

flexibility[,fleksɪ'bɪlɪtɪ]n. 灵活性;弹性;适应性

consider[kən'sɪdə]vt. 考虑;认为;考虑到;细想

suitable['suːtəb(ə)l]adj. 适当的;相配的

processor['prəʊsesə]n. [计] 处理器;处理程序;加工者

intensive[ɪn'tensɪv]adj. 加强的;集中的;透彻的;加强语气的

alternative[ɔːl'tɜːnətɪv; ɒl-]adj. 供选择的;选择性的;交替的

primitive['prɪmɪtɪv]adj. 原始的,远古的;简单的,粗糙的

explicitly[ik'splisitli]adv. 明确地;明白地

ensure[ɪn'ʃɔː; -'ʃʊə; en-]vt. 保证,确保;使安全

consistent[kən'sɪst(ə)nt]adj. 始终如一的,一致的;坚持的

effort['efət]n. 努力;成就

layered['leɪəd]adj. 分层的;层状的

animating['ænimeitiŋ]adj. 有生气的;启发的

illusion[ɪ'l(j)uːʒ(ə)n]n. 幻觉,错觉;错误的观念或信仰

geared['gɪəd]v. 用齿轮连接;给…装上齿轮;挂档开动机器;准备好(gear的过去式)adj. 齿轮传动的,变速螺旋桨

primarily['praɪm(ə)rɪlɪ; praɪ'mer-]adv. 首先;主要地,根本上

toward[tə'wɔːd; twɔːd; tɔːd]prep. 向;对于;为了;接近

rates[reɪts]n. 价格;[数] 比率;等级(rate的复数形式)

virtual['vɜːtjʊəl]adj. [计] 虚拟的;有效的;实质上的,事实上的

prototype['prəʊtətaɪp]n. 原型;标准,模范

mechanical[mɪ'kænɪk(ə)l]adj. 机械的;力学的;呆板的;无意识的;手工操作的

architectural[,ɑːkɪ'tektʃərəl]adj. 建筑学的;建筑上的;符合建筑法的

conform[kən'fɔːm]vi. 符合;遵照;适应环境

specification[,spesɪfɪ'keɪʃ(ə)n]n. 规格;说明书;详述

immersiven. 沉浸式;沉浸感;增加沉浸感

extensive[ɪk'stensɪv; ek-]adj. 广泛的;大量的;广阔的

utility[juːˈtɪləti]n. 实用;效用;公共设施;功用

productivity[prɒdʌk'tɪvɪtɪ]n. 生产力;生产率;生产能力

dynamically[dai'næmikəli]adv. 动态地;充满活力地;不断变化地

track[træk]vt. 追踪;通过;循路而行;用纤拉

constantly['kɒnst(ə)ntlɪ]adv. 不断地;时常地

appropriate[ə'prəʊprɪət]adj. 适当的

bulk[bʌlk]n. 体积,容量;大多数,大部分;大块

fixed[fɪkst]adj. 固执的;<美口>处境...的;准备好的;确定的

render['rendə]vt. 致使;提出;实施;着色;以…回报

in advanceadv. 预先,提前

interactivity[,intəræk'tiviti]n. 交互性;互动性

electronic[ɪlek'trɒnɪk; el-]adj. 电子的

board[bɔːd]n. 董事会;木板;甲板;膳食

generally['dʒen(ə)rəlɪ]adv. 通常;普遍地,一般地

superimpose[,suːp(ə)rɪm'pəʊz; ,sjuː-]vt. 添加;重叠;附加;安装

few[fjuː]adj. 很少的;几乎没有的

concept['kɒnsept]n. 观念,概念

underpin[ʌndə'pɪn]vt. 巩固;支持;从下面支撑;加强…的基础

be familiar with  熟悉,知道

rendering['rend(ə)rɪŋ]n. 翻译;表现;表演;描写;打底;(建筑物等)透视图

perform[pə'fɔːm]vt. 执行;完成;演奏

stroke[strəʊk]vt. 抚摸;敲击;划尾桨;划掉

clipping['klɪpɪŋ]n. 剪裁,剪断;剪报,剪辑;剪下物,剪下的东西

origin['ɒrɪdʒɪn]n. 起源;原点;出身;开端

positive['pɒzɪtɪv]n. 正数;[摄] 正片

extend[ɪk'stend; ek-]vt. 延伸;扩大;推广;伸出;给予;使竭尽全力;对…估价

downward['daʊnwəd]adj. 向下的,下降的

orientation[,ɔːrɪən'teɪʃ(ə)n; ,ɒr-]n. 方向;定向;适应;情况介绍;向东方

underlying[ʌndə'laɪɪŋ]v. 放在…的下面;为…的基础;优先于(underlie的ing形式)

matrix['meɪtrɪks]n. [数] 矩阵;模型;[生物][地质] 基质;母体;子宫;[地质] 脉石

logical['lɒdʒɪk(ə)l]adj. 合逻辑的,合理的;逻辑学的

measure['meʒə]vt. 测量;估量;权衡

pixel['pɪks(ə)l; -sel]n. (显示器或电视机图象的)像素(等于picture element)

precision[prɪ'sɪʒ(ə)n]n. 精度,[数] 精密度;精确

expressed[ɪk'spresɪd]v. 表达( express的过去式和过去分词 );(用符号等)表示;榨;

complementary[kɒmplɪ'ment(ə)rɪ]adj. 补足的,补充的

capability[keɪpə'bɪlɪtɪ]n. 才能,能力;性能,容量

encompass[ɪn'kʌmpəs; en-]vt. 包含;包围,环绕;完成

Bézier  贝兹曲线 补充一下,一般常用的向量有贝兹曲线(Bézier)或非均匀有理曲线(NURBS),前者多用在2D向量绘图软体,后者则常用在3D绘图软体中。

transparency[træn'spær(ə)nsɪ; trɑːn-; -'speə-]n. 透明,透明度;幻灯片;有图案的玻璃

gradient['greɪdɪənt]n. [数][物] 梯度;坡度;倾斜度

mask[mɑːsk]n. 面具;口罩;掩饰

fluid['fluːɪdadj. 流动的;流畅的;不固定的

manipulating[məˈnipjuleitɪŋ]v. 操纵;假造;手动(manipulate的ing形式

scale down按比例减少;按比例缩小

photographs['fəutəgræfs]n. 照片;逼真的描绘(photograph的复数)

storage['stɔːrɪdʒ]n. 存储;仓库;贮藏所

relevant['relɪv(ə)nt]adj. 相关的;切题的;中肯的;有重大关系的;有意义的,目的明确的

wireless['waɪəlɪs]adj. 无线的;无线电的

assemblie 集合 装配

minimal['mɪnɪm(ə)l]adj. 最低的;最小限度的

involvement[ɪn'vɒlvm(ə)nt]n. 牵连;包含;混乱;财政困难

assign[ə'saɪn]vt. 分配;指派;[计][数] 赋值

renderern. 渲染器;描绘器

resolution[rezə'luːʃ(ə)n]n. [物] 分辨率;决议;解决;决心

rest[rest]n. 休息,静止;休息时间;剩余部分;支架

scale[skeɪl]n. 规模;比例;鳞;刻度;天平;数值范围

factor['fæktə]n. 因素;要素;[物] 因数;代理人

3 结语

  以上是所有内容,希望对大家有所帮助。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值