drawing ios_unity system.drawing ios - CSDN
  • iOSDrawing

    2014-03-07 10:19:13
    14.1 Quartz概述 14.2 绘制基本几何图形 14.3 绘制图像和文本 14.4 坐标 14.5 变换 14.6 图像拾取器 ...Quartz是Mac OS X的Darwin核心之上的绘图层,有时候也认为是CoreGraphics。...Quartz Compositor,合成

    14.1 Quartz概述

    14.2 绘制基本几何图形

    14.3 绘制图像和文本

    14.4 坐标

    14.5 变换

    14.6 图像拾取器

     

    14.1 Quartz概述

    Quartz是Mac OS X的Darwin核心之上的绘图层,有时候也认为是CoreGraphics。共有两种部分组成Quartz:

    Quartz Compositor,合成视窗系统,管理和合成幕后视窗影像来建立Mac OS X使用者接口。

    Quartz 2D,是iOS和Mac OS X环境下的二维绘图引擎。

    涉及内容包括:基于路径的绘图,透明度绘图,遮盖,阴影,透明层,颜色管理,防锯齿渲染,生成PDF,以及PDF元数据相关处理。

    14.2 绘制基本几何图形

    视图绘制

        在iOS上,所有的绘制,无论是否采用OpenGL、Quartz、UIKit、或者 Core Animation—都发生在UIView对象的区域内。

    视图定义绘制发生的屏幕区域。如果您使用系统提供的视图,绘制工作会自动得到处理。然而,如果您定义自己的定制视图,则必须自行提供绘制代码。

    对于使用OpenGL进行绘制的应用程序,一旦建立了渲染表面,就必须使用OpenGL指定的绘制模型。

    视图绘制周期

        描绘系统会调用UIView对象的drawRect:方法,并向它传入一个包含需要重画的视图区域的矩形。触发视图更新的动作有如下几种:

    对遮挡您的视图的其它视图进行移动或删除操作。 

    将视图的hidden属性声明设置为NO,使其从隐藏状态变为可见。

    将视图滚出屏幕,然后再重新回到屏幕上。

    显式调用视图的setNeedsDisplay或者setNeedsDisplayInRect:方法。

    setNeedsDisplay是更新整个视图,

    setNeedsDisplayInRect是更新视图的部分区域。

    视图绘制实例FirstQuartz2D

    wps_clip_image-14312

    自定义视图的h文件

    @interface MyView : UIView {
        
    }
    
    @end

    自定义视图的m文件 

    复制代码
    @implementation MyView
    
    - (void)drawRect:(CGRect)rect {
        
        CGContextRef context = UIGraphicsGetCurrentContext();
        
        CGContextMoveToPoint (context, 75, 10); 
        CGContextAddLineToPoint (context, 10, 150); 
        CGContextAddLineToPoint (context, 160, 150); 
        
        // Closing the path connects the current point to the start of the current path.
        CGContextClosePath(context);
        // And stroke the path
        [[UIColor blackColor] setStroke]; 
        //CGContextStrokePath(context);
        [[UIColor redColor] setFill]; 
        CGContextDrawPath(context, kCGPathFillStroke);
        //kCGPathFillStroke,kCGPathFill,kCGPathStroke
        
    
    }
    
    @end
    复制代码

    CGContextRef context = UIGraphicsGetCurrentContext();可以获得图形上下文。

    CGContextMoveToPoint、CGContextAddLineToPoint两个函数是构建描绘路径。

    CGContextClosePath(context);函数是闭合描绘路径。

    CGContextStrokePath函数是为闭合路径描边。

    [[UIColor blackColor] setStroke]设置描边的颜色。

    [[UIColor redColor] setFill]设置要填充颜色。

    CGContextDrawPath(context, kCGPathFillStroke);设置描绘路径方式。常用的还有:

    kCGPathFill和kCGPathStroke

    图形上下文

      在调用您提供的drawRect:方法之前,视图对象会自动配置其绘制环境,使您的代码可以立即进行绘制。作为这些

    配置的一部分,UIView对象会为当前绘制环境创建一个图形上下文(对应于CGContextRef封装类型)。

      该图形上下文包含绘制系统执行后续绘制命令所需要的信息,定义了各种基本的绘制属性,比如绘制使用的颜色、

    裁剪区域、线的宽度及风格信息、字体信息、合成选项、以及几个其它信息。

    绘制路径

      路径用于描述由一序列线和Bézier曲线构成的2D几何形状。Core Graphics中也有一些用于创建简单路径(比如矩形和椭圆形)的便利函数。对于更为复杂的路径,必须用Core Graphics框架提供的函数自行创建。

      Bézier曲线是法国数学家“贝塞尔”在工作中发现,任何一条曲线都可以通过与它相切的控制线两端的点的位置来定义。

    Bézier曲线

    wps_clip_image-26605

    Bézier曲线实例BezierCurve

    wps_clip_image-32456

    复制代码
    - (void)drawRect:(CGRect)rect {
        
        CGContextRef cgContext = UIGraphicsGetCurrentContext();
        
        //CGContextBeginPath(cgContext);
        CGContextMoveToPoint(cgContext, 333, 0);
        CGContextAddCurveToPoint(cgContext, 333, 0, 332, 26, 330, 26);
        CGContextAddCurveToPoint(cgContext, 330, 26, 299, 20, 299, 17);
        CGContextAddLineToPoint(cgContext, 296, 17);
        CGContextAddCurveToPoint(cgContext, 296, 17, 296, 19, 291, 19);
        CGContextAddLineToPoint(cgContext, 250, 19);
        CGContextAddCurveToPoint(cgContext, 250, 19, 241, 24, 238, 19);
        CGContextAddCurveToPoint(cgContext, 236, 20, 234, 24, 227, 24);
        CGContextAddCurveToPoint(cgContext, 220, 24, 217, 19, 216, 19);
        CGContextAddCurveToPoint(cgContext, 214, 20, 211, 22, 207, 20);
        CGContextAddCurveToPoint(cgContext, 207, 20, 187, 20, 182, 21);
        CGContextAddLineToPoint(cgContext, 100, 45);
        CGContextAddLineToPoint(cgContext, 97, 46);
        CGContextAddCurveToPoint(cgContext, 97, 46, 86, 71, 64, 72);
        CGContextAddCurveToPoint(cgContext, 42, 74, 26, 56, 23, 48);
        CGContextAddLineToPoint(cgContext, 9, 47);
        CGContextAddCurveToPoint(cgContext, 9, 47, 0, 31, 0, 0);
        
        CGContextStrokePath(cgContext);
    }
    复制代码

    14.3 绘制图像和文本

    UIImages的-drawRect:方法绘制图像:

    - [UIImage drawAtPoint:(CGPoint)point] 

    - [UIImage drawInRect:(CGRect)rect]

    - [UIImage drawAsPatternInRect:(CGRect)rect]

    NSString的-drawRect:方法绘制文本:  

    - [NSString drawAtPoint:(CGPoint)point withFont:(UIFont *)font]

    实例DrawImage

    wps_clip_image-11683

    复制代码
    #import "MyView.h"
    
    
    @implementation MyView
    
    - (void)drawRect:(CGRect)rect {
        
        NSString* imagePath = [[NSBundle mainBundle] pathForResource:@"dog" ofType:@"png"];
        UIImage* myImageObj = [[UIImage alloc] initWithContentsOfFile:imagePath];
        //[myImageObj drawAtPoint:CGPointMake(0, 0)];
        [myImageObj drawInRect:CGRectMake(0, 0, 320, 480)];
        
        NSString *s = @"我的小狗";
        
        [s drawAtPoint:CGPointMake(100, 0) withFont:[UIFont systemFontOfSize:34.0]];
    }
    
    @end
    复制代码

    写字实例Draw

    wps_clip_image-23850

    Dot对象

    复制代码
    //--h
    @interface Dot : NSObject {
      CGFloat x;
      CGFloat y;
    }
    
    @property(assign) CGFloat x;
    @property(assign) CGFloat y;
    
    @end
    
    //--m
    #import "Dot.h"
    @implementation Dot
    
    @synthesize x;
    @synthesize y;
    
    @end
    复制代码

    DrawView.h 

    复制代码
    #import <UIKit/UIKit.h>
    
    @interface DrawView : UIView {
      NSMutableArray *dots;
    }
    
    @property(nonatomic, retain) NSMutableArray *dots;
    
    @end
    复制代码

    DrawView.m

     

    复制代码
    #import "DrawView.h"
    #import "Dot.h"
    
    @implementation DrawView
    
    @synthesize dots;
    
    - (NSMutableArray *)dots {
        if(nil == dots) {
            self.dots = [NSMutableArray array];
        }
        return dots;
    }
    //START:code.DrawView.drawRect
    - (void)drawRect:(CGRect)rect {
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(ctx, [[UIColor blueColor] CGColor]);
        for(Dot *dot in self.dots) {
            CGContextAddArc(ctx, dot.x, dot.y, 5.0f, 0.0f, 2.0f * M_PI, YES);
            CGContextFillPath(ctx);
        }
        
    }
    //END:code.DrawView.drawRect
    
    - (void)dealloc {
        self.dots = nil;
        [super dealloc];
    }
    复制代码

    drawRect方法中将dots集合中的Dot对象取出,一个一个在屏幕上面画出来。

    CGContextAddArc(ctx, dot.x, dot.y, 5.0f, 0.0f, 2.0f * M_PI, YES);函数是绘制弧形。

    CGContextFillPath(ctx);填充路径。

    复制代码
    //START:code.DrawView.touchesBegan
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        CGPoint location = [touch locationInView:self];
        Dot *dot = [[[Dot alloc] init] autorelease];
        dot.x = location.x;
        dot.y = location.y;
        //[self.dots removeAllObjects];
        [self.dots addObject:dot];
        [self setNeedsDisplay];
    }
    //END:code.DrawView.touchesBegan
    
    //START:code.DrawView.touchesMoved
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        CGPoint location = [touch locationInView:self];
        Dot *dot = [[[Dot alloc] init] autorelease];
        dot.x = location.x;
        dot.y = location.y;
        [self.dots addObject:dot];
        [self setNeedsDisplay];
    }
    //END:code.DrawView.touchesMoved
    复制代码

     

    14.4 坐标

    Quartz坐标

    Quartz技术最开始为Mac OS X系统设计的图形技术,它的坐标原点位于左下角。

    wps_clip_image-1616

    UIKit坐标

    UIKit坐标与Quartz不同,原点位于右上角。在iOS中的UIView等控件都是基于此坐标,由于在UIView使用了Quartz坐标有时候需要转换。

    wps_clip_image-5807

    坐标变换实例

    wps_clip_image-29340

    MyView.m文件

    复制代码
    #import "MyView.h"
    
    @implementation MyView
    
    - (void)drawRect:(CGRect)rect {
    
        NSString *path = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"jpg"];
        UIImage *img = [UIImage imageWithContentsOfFile:path];
        CGImageRef image = img.CGImage;
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSaveGState(context);
        
        CGRect touchRect = CGRectMake(0, 0, img.size.width, img.size.height);
        CGContextDrawImage(context, touchRect, image);  
        CGContextRestoreGState(context);
    }
    @end
    复制代码

     

    CGContextSaveGState是将当前图形状态要入到图形堆栈。

    CGContextDrawImage(context, touchRect, image)在上下文中绘制图形。 CGContextRestoreGState回复当前图形状态。

    14.5 变换

    运用变换 

    变换(transformation)修改了图形上下文中绘制图形的方式。可以通过移动、旋转或缩放实现变换。

    Quartz提供了多种形式的变换,其中主要:CTM(当前变换矩阵)变换和仿射(affine)变换。

    CTM(current transformation matrix)变换,这种变换比较简单,函数有:

    CGContextRotateCTM,旋转坐标

    CGContextScaleCTM,缩放坐标

    CGContextTranslateCTM,移动原点

    移动变换

    CGContextTranslateCTM (myContext, 100, 50)

    wps_clip_image-23595

    从对象角度沿着x轴正向移动100单位,沿着y轴正向移动50单位。

    旋转变换

    static inline double radians (double degrees) {return degrees * M_PI/180;}

    CGContextRotateCTM (myContext, radians(–45.));

    wps_clip_image-9368

    从对象角度:

    在Quartz坐标下正数为逆时针旋转,负数为顺时针旋转。

    在UIKit坐标下正数为顺时针旋转,负数为逆时针旋转。

    缩放变换

    CGContextScaleCTM (myContext, .5, .75);

    wps_clip_image-14003

    从对象角度:所有x坐标缩小0.5,所有y坐标缩小0.75。

    修改MyView.m文件

    复制代码
    #import "MyView.h"
    
    @implementation MyView
    
    - (void)drawRect:(CGRect)rect {
    
        NSString *path = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"jpg"];
        UIImage *img = [UIImage imageWithContentsOfFile:path];
        CGImageRef image = img.CGImage;
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSaveGState(context);
        
        CGContextRotateCTM(context, M_PI);
        CGContextTranslateCTM(context, -img.size.width, -img.size.height);
        
        CGRect touchRect = CGRectMake(0, 0, img.size.width, img.size.height);
        CGContextDrawImage(context, touchRect, image);  
        CGContextRestoreGState(context);
    }
    @end
    复制代码

     

    仿射(affine)变换

    仿射(affine)变换也是一种直角坐标变换,重

    用变换,经过多次变换(多次的矩阵相乘),

    每一种变换都可以用矩阵表示,通过多次矩阵

    相乘得到最后结果。仿射变换函数:

        CGAffineMakeRotation,创建旋转矩阵仿射对象

        CGAffineMakeScale,创建缩放矩阵仿射对象

        CGAffineMakeTranslation,创建移动矩阵仿射对象

        CGAffineTransformRotate,旋转矩阵仿射对象

        CGAffineTransformScale,缩放矩阵仿射对象

        CGAffineTransformTranslate,移动矩阵仿射对象

        CGContextConcatCTM,连接到CTM变换

    使用仿射变换MyView.m

    复制代码
    #import "MyView.h"
    
    @implementation MyView
    
    - (void)drawRect:(CGRect)rect {
    
        NSString *path = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"jpg"];
        UIImage *img = [UIImage imageWithContentsOfFile:path];
        CGImageRef image = img.CGImage;
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSaveGState(context);
        
        CGAffineTransform myAffine = CGAffineTransformMakeRotation(M_PI); 
        myAffine = CGAffineTransformTranslate(myAffine, -img.size.width, -img.size.height); 
        CGContextConcatCTM(context, myAffine);
        
        CGContextRotateCTM(context, M_PI);
        CGContextTranslateCTM(context, -img.size.width, -img.size.height);
        
        CGRect touchRect = CGRectMake(0, 0, img.size.width, img.size.height);
        CGContextDrawImage(context, touchRect, image);  
        CGContextRestoreGState(context);
    }
    @end
    复制代码

     

    14.6 图像拾取器

    图像拾取器(Image Picker)是可以帮助你从图片库中选取图片,也可以捕获照相机图片。

    wps_clip_image-22106

    wps_clip_image-8654

    PhotoViewViewController.h

    复制代码
    //START:code.PhotoViewController.h
    @interface PhotoViewViewController : UIViewController
    <UIImagePickerControllerDelegate> {
        UIImageView *imageView;
        UIImagePickerController *imagePicker;
    }
    
    @property(nonatomic, retain) IBOutlet UIImageView *imageView;
    @property(nonatomic, retain) IBOutlet UIImagePickerController *imagePicker;
    
    @end
    //END:code.PhotoViewController.h
    复制代码

     

    需要实现UIImagePickerControllerDelegate协议。

    需要定义UIImagePickerController控制器成员变量。

    PhotoViewViewController.m

    复制代码
    #import "PhotoViewViewController.h"
    
    @implementation PhotoViewViewController
    
    @synthesize imageView;
    @synthesize imagePicker;
    
    //START:code.PhotoViewController.touchesEnded:withEvent:
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        if([[touches anyObject] tapCount] > 1) {
            // bring up image grabber
            if([UIImagePickerController isSourceTypeAvailable:
                UIImagePickerControllerSourceTypeCamera]) {
                self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            } else {
                self.imagePicker.sourceType =
                UIImagePickerControllerSourceTypePhotoLibrary;
            }
            //self.imagePicker.allowsImageEditing = YES; //iOS 3之前
            self.imagePicker.allowsEditing = YES; 
            
            [self presentModalViewController:self.imagePicker animated:YES]; 
        }
    }
    //END:code.PhotoViewController.touchesEnded:withEvent:
    复制代码

     

    图像选取器的sourceType属性有:

    UIImagePickerControllerSourceTypePhotoLibrary,图片来源于“相簿”

    UIImagePickerControllerSourceTypeCamera,来源于相机

    UIImagePickerControllerSourceTypeSavedPhotosAlbum,来源于“相机胶卷”。

    PhotoViewViewController.m

    复制代码
    //START:code.PhotoViewController.didFinish
    - (void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingMediaWithInfo:(NSDictionary *)info {
        imageView.image = [info objectForKey:UIImagePickerControllerEditedImage]; 
        [self dismissModalViewControllerAnimated:YES]; 
    }
    //END:code.PhotoViewController.didFinish
    
    //START:code.PhotoViewController.didCancel
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
        [self.imagePicker dismissModalViewControllerAnimated:YES];
    }
    //END:code.PhotoViewController.didCancel
    
    - (void)dealloc {
        self.imageView = nil;
        self.imagePicker = nil;
        [super dealloc];
    }
    复制代码

     

    imagePickerController:didFinishPickingMediaWithInfo:委托实现方法,当选择完成时候调用。

    imageView.image = [info objectForKey:UIImagePickerControllerEditedImage];语句可以从图片拾取器中获得一个Image对象。

    imagePickerControllerDidCancel:是委托实现方法当点击取消时候调用。

    本文转自:http://blog.163.com/wkyuyang_001/blog/static/10802122820133190545227/

    展开全文
  • iOSDrawing<2>

    2015-11-12 21:49:33
    图形上下文(Graphics Contexts)我们可以使用代码来创建图画,图形上下文是可以绘画的地方。这里推荐两种获取图形上下文的方法: 创建一个图片上下文(image context) 函数UIGraphicsBeginImageContextWithOptions...

    图形上下文(Graphics Contexts)

    我们可以使用代码来创建图画,图形上下文是可以绘画的地方。这里推荐两种获取图形上下文的方法:

    • 创建一个图片上下文(image context)
      函数UIGraphicsBeginImageContextWithOptions用来创建一个图形上下文,接着你可以在上面绘制来产生图片,然后通过UIGraphicsGetImageFromCurrentImageContext来将上下文转变为UIImage,最后使用UIGraphicsEndImageContext关闭上下文。
    • Cocoa交给你一个图形上下文(graphics context)
      子类化UIView,然后实现drawRect:。在drawRect:被调用时,Cocoa已经创建了一个图形上下文,你在上面绘制什么,UIView就展示什么。

    进一步,注意当前图形上下文:

    • UIGraphicsBeginImageContextWithOptions函数不仅仅创建一个图片上下文,它也会让刚创建的上下文成为当前的图形上下文。
    • drawRect:被调用的时候,UIView的绘图上下文已经是当前的图形上下文了。
    • 带有context:参数的回调并没让任何一个上下文成为当前的图形上下文。这个参数是图形上下文的引用,你将会在上面绘制图形,所以你要确保让它成为当前的上下文。

    有两种工具可以绘制图形:

    • UIKit
      许多Cocoa类都知道如何绘制自己,包括UIImage,NSString(绘制文本),UIBezierPath(绘制形状),和UIColor。一些类提供便利方法,但是能力有限;其它类是相当强大的。

    如果是通过context:参数传入图形上下文的话,你可以通过UIGraphicsPushContext方法来使传进来的上下文成为当前上下文,确保稍后调用UIGraphicsPopContext恢复到以前状态。
    - Core Graphics
    这是强大的绘图API。Core Graphics通常指的是Quartz或者Quartz 2D,是位于所有iOS绘图之下的绘图系统,UIKit也是建立在其之上,所以,它是底层的,由C函数组成的。

    使用Core Graphics,你必须要声明一个绘图上下文(CGContext)来在上面绘图。如果是通过context:参数传入的图形上下文的话,那个就是你要在上面绘图的上下文;但是在UIGraphicsBeginImageContextWithOptions或者drawRect:情况下,你没有对上下文的引用,为了使用Core Graphics,你必须要得到引用。因为你想要绘制的就是当前上下文,所以可以调用UIGraphicsGetCurrentContext获得引用。

    1.实现UIView子类的drawRect:方法,使用UIKit在当前上下文中进行绘图:

    override func drawRect(rect: CGRect) {
            let p=UIBezierPath(ovalInRect: CGRectMake(0, 0, 100, 100))
            UIColor.blueColor().setFill()
            p.fill()
        }

    2.使用Core Graphics实现相同的事情:

    override func drawRect(rect: CGRect) {
            let con=UIGraphicsGetCurrentContext()!
            CGContextAddEllipseInRect(con, CGRectMake(0, 0, 100, 100))
            CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
            CGContextFillPath(con)
        }

    3.实现UIView子类的drawLayer:inContext:方法,这种情况下,有一个上下文的引用,但它不是当前上下文,所以必须使它成为当前上下文来使用UIKit:

        override func drawLayer(layer: CALayer, inContext ctx: CGContext) {  
           UIGraphicsPushContext(ctx)
            let p=UIBezierPath(ovalInRect: CGRectMake(0, 0, 100, 100))
            UIColor.redColor().setFill()
            p.fill()
            UIGraphicsPopContext()
        }

    4.使用Core Graphics实现上面的效果:

    ```
        override func drawLayer(layer: CALayer, inContext ctx: CGContext) {  
           CGContextAddEllipseInRect(ctx, CGRectMake(0, 0, 100, 100))
            CGContextSetFillColorWithColor(ctx, UIColor.blueColor().CGColor)
            CGContextFillPath(ctx)
        }

    5.最后,来制作一个UIImage,我们可以在任何时候完成这个任务。产生的UIImage可以用在任何地方:

    使用UIKit:

    override func viewDidLoad() {
            super.viewDidLoad()
            let draw=UIImageView()
            draw.frame=CGRectMake(100, 100, 100, 100)
    
            UIGraphicsBeginImageContextWithOptions(CGSize(width: 100, height: 100), false, 1.0)
            let p=UIBezierPath(ovalInRect: CGRectMake(0, 0, 100, 100))
            UIColor.blueColor().setFill()
            p.fill()
    
            let im:UIImage=UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
    
            draw.image=im
    
            self.view.addSubview(draw)
        }
    

    使用Core Graphics:

    verride func viewDidLoad() {
            super.viewDidLoad()
    
            let draw=UIImageView()
            draw.frame=CGRectMake(100, 100, 100, 100)
    
            UIGraphicsBeginImageContextWithOptions(CGSize(width: 100, height: 100), false, 1.0)
            let con=UIGraphicsGetCurrentContext()
            CGContextAddEllipseInRect(con, CGRectMake(0, 0, 100, 100))
            CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
            CGContextFillPath(con)
    
            let im:UIImage=UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
    
            draw.image=im
    
            self.view.addSubview(draw)
        }
    展开全文
  • iOS drawing 绘图简介

    2015-03-31 15:43:49
    重新创建一个UIView类,在实现文件里写draw方法,再在其他视图控制器里引用(MyView)即可。 #import "MyView.h" @implementation MyView - (instancetype)initWithFrame:...initWithFrame:frame]

           重新创建一个UIView类,在实现文件里写draw方法,再在其他视图控制器里引用(MyView)即可。


    #import "MyView.h"

    @implementation MyView

    - (instancetype)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self) {

            self.backgroundColor = [UIColor yellowColor];

        }

        return self;

    }

    /*

    // Only override drawRect: if you perform custom drawing.

    // An empty implementation adversely affects performance during animation.

     */

    - (void)drawRect:(CGRect)rect {

        // Drawing code

        // 获得设备上下文 把视图当做画布

        CGContextRef context = UIGraphicsGetCurrentContext();

        // 线

        // 移动画笔到线的起点

        CGContextMoveToPoint(context, 0, 0);

        // 移动画笔到线的终点

        CGContextAddLineToPoint(context, 100, 100);

        // 给线涂色

        CGContextStrokePath(context);

        

        // 矩形框

        CGContextStrokeRect(context, CGRectMake(80, 150, 50, 50));

        // 实心矩形

        CGContextFillRect(context, CGRectMake(80, 210, 50, 50));

        

        // 圆形框

        CGContextStrokeEllipseInRect(context, CGRectMake(80, 270, 50, 50));

        // 实心圆

        CGContextFillEllipseInRect(context, CGRectMake(80, 330, 50, 50));

        

        // 文字

        NSString *str = @"绘图的简单介绍--不喜勿喷";

        [str drawAtPoint:CGPointMake(150, 200) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13], NSFontAttributeName, nil]];

    }

    @end



    展开全文
  • iOS Drawing Concepts High-quality graphics are an important part of your app’s user interface. Providing high-quality graphics not only makes your app look good, but it also makes your app look like ...

    iOS Drawing Concepts

    High-quality graphics are an important part of your app’s user interface. Providing high-quality graphics not only makes your app look good, but it also makes your app look like a natural extension to the rest of the system. iOS provides two primary paths for creating high-quality graphics in your system: OpenGL or native rendering using Quartz, Core Animation, and UIKit. This document describes native rendering. (To learn about OpenGL drawing, see OpenGL ES Programming Guide.)

    Quartz is the main drawing interface, providing support for path-based drawing, anti-aliased rendering, gradient fill patterns, images, colors, coordinate-space transformations, and PDF document creation, display, and parsing. UIKit provides Objective-C wrappers for line art, Quartz images, and color manipulations. Core Animation provides the underlying support for animating changes in many UIKit view properties and can also be used to implement custom animations.

    This chapter provides an overview of the drawing process for iOS apps, along with specific drawing techniques for each of the supported drawing technologies. You will also find tips and guidance on how to optimize your drawing code for the iOS platform.

    Important: Not all UIKit classes are thread safe. Be sure to check the documentation before performing drawing-related operations on threads other than your app’s main thread.

    高质量的图形(graphics)是应用程序用户界面的重要组成部分。 提供高质量的图形不仅使您的应用程序看起来很好,而且还使您的应用程序看起来像是系统其余部分的自然扩展。 iOS提供了两种在系统中创建高质量图形的主要途径:①OpenGL, ②使用Quartz,Core Animation和UIKit的自然渲染(native rendering)。 本文档描述了自然渲染。 (要了解OpenGL绘图,请参阅OpenGL ES Programming Guide。)

    Quartz是主要的绘图接口,支持基于路径的绘制,消除锯齿渲染,渐变填充图案,图像,颜色,坐标空间转换以及PDF文档创建,显示和解析。 UIKit为线条艺术,石英图像和颜色处理提供Objective-C包装。 Core Animation为许多UIKit视图属性中的动画更改提供了底层支持,也可用于实现自定义动画。

    本章概述了iOS应用程序的绘图过程,以及每种支持的绘图技术的特定绘图技术。 您还可以找到有关如何针对iOS平台优化绘图代码的提示和指导。

    重要提示:并非所有UIKit类都是线程安全的。 在对应用程序主线程以外的线程执行与绘图相关的操作之前,请务必检查文档。

    The UIKit Graphics System (UIKit 图形系统)

    In iOS, all drawing to the screen—regardless of whether it involves OpenGL, Quartz, UIKit, or Core Animation—occurs within the confines of an instance of the UIView class or a subclass thereof. Views define the portion of the screen in which drawing occurs. If you use system-provided views, this drawing is handled for you automatically. If you define custom views, however, you must provide the drawing code yourself. If you use Quartz, Core Animation, and UIKit to draw, you use the drawing concepts described in the following sections.

    In addition to drawing directly to the screen, UIKit also allows you to draw into offscreen bitmap and PDF graphics contexts. When you draw in an offscreen context, you are not drawing in a view, which means that concepts such as the view drawing cycle do not apply (unless you then obtain that image and draw it in an image view or similar).

    在iOS中,所有对于屏幕的绘制 - 无论是涉及OpenGL,Quartz,UIKit还是Core Animation - 都发生在UIView类的实例或其子类的范围内。 视图定义了发生绘图的屏幕部分。 如果使用系统提供的视图,则会自动为您处理此图形。 但是,如果定义自定义视图,则必须自己提供绘图代码。 如果使用Quartz,Core Animation和UIKit进行绘制,则可以使用以下各节中描述的绘图概念。

    除了直接绘制到屏幕,UIKit还允许您绘制到屏幕外位图和PDF图形上下文。 当你在离屏上下文中绘制时,您并不是在一个视图中绘制,这意味着视图绘制周期等概念不适用(除非您获取该图像并在图像视图中绘制它或类似图像)。

    The View Drawing Cycle (视图绘制周期)

    The basic drawing model for subclasses of the UIView class involves updating content on demand. The UIView class makes the update process easier and more efficient; however, by gathering the update requests you make and delivering them to your drawing code at the most appropriate time.

    When a view is first shown or when a portion of the view needs to be redrawn, iOS asks the view to draw its content by calling the view’s drawRect: method.

    UIView类的子类的基本绘图模型涉及按需更新内容。 UIView类使更新过程更容易,更有效; 但是,通过收集更新请求,您可以在最合适的时间将它们交付给您的绘图代码。

    首次显示视图或需要重绘视图的一部分时,iOS会要求视图通过调用视图的drawRect:方法来绘制其内容。

    There are several actions that can trigger a view update:

    • Moving or removing another view that was partially obscuring your view
    • Making a previously hidden view visible again by setting its hidden property to NO
    • Scrolling a view off of the screen and then back onto the screen
    • Explicitly calling the setNeedsDisplay or setNeedsDisplayInRect: method of your view

    有几个操作可以触发视图更新:

    • 移动或删除部分遮挡视图的其他视图
    • 通过将其隐藏属性设置为NO,可以再次显示先前隐藏的视图
    • 滚动屏幕上的视图,然后返回到屏幕上
    • 显式调用视图的setNeedsDisplaysetNeedsDisplayInRect:方法

    System views are redrawn automatically. For custom views, you must override the drawRect: method and perform all your drawing inside it. Inside your drawRect: method, use the native drawing technologies to draw shapes, text, images, gradients, or any other visual content you want. The first time your view becomes visible, iOS passes a rectangle to the view’s drawRect: method that contains your view’s entire visible area. During subsequent calls, the rectangle includes only the portion of the view that actually needs to be redrawn. For maximum performance, you should redraw only affected content.

    After calling your drawRect: method, the view marks itself as updated and waits for new actions to arrive and trigger another update cycle. If your view displays static content, then all you need to do is respond to changes in your view’s visibility caused by scrolling and the presence of other views.

    If you want to change the contents of the view, however, you must tell your view to redraw its contents. To do this, call the setNeedsDisplay or setNeedsDisplayInRect: method to trigger an update. For example, if you were updating content several times a second, you might want to set up a timer to update your view. You might also update your view in response to user interactions or the creation of new content in your view.

    Important: Do not call your view’s drawRect: method yourself. That method should be called only by code built into iOS during a screen repaint. At other times, no graphics context exists, so drawing is not possible. (Graphics contexts are explained in the next section.)

    系统视图会自动重绘。对于自定义视图,您必须覆盖drawRect:方法并在其中执行所有绘图。在drawRect:方法中,使用本机绘图技术绘制所需的形状,文本,图像,渐变或任何其他可视内容。第一次看到您的视图时,iOS会将一个矩形传递给视图的drawRect:方法,该方法包含视图的整个可见区域。在后续调用期间,矩形仅包括实际需要重绘的视图部分。为获得最佳性能,您应仅重绘受影响的内容。

    在调用drawRect:方法之后,视图将自身标记为已更新,并等待新操作到达并触发另一个更新周期。如果您的视图显示静态内容,那么您需要做的就是响应视图因滚动和其他视图的存在而导致的可见性变化。

    但是,如果要更改视图的内容,则必须告诉视图重绘其内容。为此,请调用setNeedsDisplaysetNeedsDisplayInRect:方法以触发更新。例如,如果您每秒多次更新内容,则可能需要设置计时器以更新视图。您还可以更新视图以响应用户交互或在视图中创建新内容。

    重要提示:请勿自行调用视图的drawRect:方法。 只有在屏幕重绘期间内置于iOS中的代码才能调用该方法。 在其他时候,不存在图形上下文,因此无法绘图。 (图形上下文将在下一节中介绍。)

    Coordinate Systems and Drawing in iOS

    When an app draws something in iOS, it has to locate the drawn content in a two-dimensional space defined by a coordinate system. This notion might seem straightforward at first glance, but it isn’t. Apps in iOS sometimes have to deal with different coordinate systems when drawing.

    当应用程序在iOS中绘制内容时,它必须在由二维空间定义的坐标系中定位绘制的内容。乍一看,这个概念似乎很简单,但事实并非如此。 iOS中的应用有时必须在绘图时处理不同的坐标系。

    In iOS, all drawing occurs in a graphics context. Conceptually, a graphics context is an object that describes where and how drawing should occur, including basic drawing attributes such as the colors to use when drawing, the clipping area, line width and style information, font information, compositing options, and so on.

    在iOS中,所有绘图都在图形上下文中进行。从概念上讲,图形上下文是描述绘图应在何处以及如何发生的对象,包括基本绘图属性,例如绘制时使用的颜色,剪切区域,线宽和样式信息,字体信息,合成选项等。

    In addition, as shown in Figure 1-1, each graphics context has a coordinate system. More precisely, each graphics context has three coordinate systems:

    另外,如图1-1所示,每个图形上下文都有一个坐标系。更确切地说,每个图形上下文都有三个坐标系:

    • The drawing (user) coordinate system. This coordinate system is used when you issue drawing commands.

    • The view coordinate system (base space). This coordinate system is a fixed coordinate system relative to the view.

    • The (physical) device coordinate system. This coordinate system represents pixels on the physical screen.

    • 绘图(用户)坐标系。发出绘图命令时使用此坐标系。

    • 视图坐标系(基本空间)。该坐标系是相对于视图的固定坐标系。

    • (物理)设备坐标系。该坐标系表示物理屏幕上的像素。

    Figure 1-1 The relationship between drawing coordinates, view coordinates, and hardware coordinates
    图1-1 绘图坐标,视图坐标和硬件坐标之间的关系
    在这里插入图片描述
    The drawing frameworks of iOS create graphics contexts for drawing to specific destinations—the screen, bitmaps, PDF content, and so on—and these graphics contexts establish the initial drawing coordinate system for that destination. This initial drawing coordinate system is known as the default coordinate system, and is a 1:1 mapping onto the view’s underlying coordinate system.

    iOS的绘图框架创建用于绘制到特定目的地的图形上下文 - 屏幕,位图,PDF内容等 - 并且这些图形上下文为该目标建立初始绘图坐标系。此初始绘图坐标系称为默认坐标系,是视图底层坐标系上的1:1映射。

    Each view also has a current transformation matrix (CTM), a mathematical matrix that maps the points in the current drawing coordinate system to the (fixed) view coordinate system. The app can modify this matrix (as described later) to change the behavior of future drawing operations.

    每个视图还具有当前变换矩阵(CTM),该数学矩阵将当前绘图坐标系中的点映射到(固定)视图坐标系。应用程序可以修改此矩阵(如稍后所述)以更改将来绘制操作的行为。

    Each of the drawing frameworks of iOS establishes a default coordinate system based on the current graphics context. In iOS, there are two main types of coordinate systems:

    An upper-left-origin coordinate system (ULO), in which the origin of drawing operations is at the upper-left corner of the drawing area, with positive values extending downward and to the right. The default coordinate system used by the UIKit and Core Animation frameworks is ULO-based.
    A lower-left-origin coordinate system (LLO), in which the origin of drawing operations is at the lower-left corner of the drawing area, with positive values extending upward and to the right. The default coordinate system used by Core Graphics framework is LLO-based.

    iOS的每个绘图框架都基于当前图形上下文建立默认坐标系。在iOS中,有两种主要类型的坐标系:

    左上原点坐标系(ULO),其中绘图操作的原点位于绘图区域的左上角,正值向下和向右延伸。 UIKit和Core Animation框架使用的默认坐标系是基于ULO的。
    左下原点坐标系(LLO),其中绘图操作的原点位于绘图区域的左下角,正值向上和向右延伸。 Core Graphics框架使用的默认坐标系是基于LLO的。

    These coordinate systems are shown in Figure 1-2.
    这些坐标系如图1-2所示。
    在这里插入图片描述

    Note: The default coordinate system in OS X is LLO-based. Although the drawing functions and methods of the Core Graphics and AppKit frameworks are perfectly suited to this default coordinate system, AppKit provides programmatic support for flipping the drawing coordinate system to have an upper-left origin.

    **注意:**OS X中的默认坐标系是基于LLO的。 虽然Core Graphics和AppKit框架的绘图功能和方法非常适合此默认坐标系,但AppKit提供了编程支持,可以将绘图坐标系翻转为左上角。

    Before calling your view’s drawRect: method, UIKit establishes the default coordinate system for drawing to the screen by making a graphics context available for drawing operations. Within a view’s drawRect: method, an app can set graphics-state parameters (such as fill color) and draw to the current graphics context without needing to refer to the graphics context explicitly. This implicit graphics context establishes a ULO default coordinate system.

    在调用视图的drawRect方法之前,UIKit通过为绘图操作提供图形上下文来建立绘制到屏幕的默认坐标系。 在视图的drawRect:方法中,应用程序可以设置图形状态参数(例如填充颜色)并绘制到当前图形上下文,而无需显式引用图形上下文。 此隐式图形上下文建立ULO默认坐标系。

    Points Versus Pixels

    In iOS there is a distinction between the coordinates you specify in your drawing code and the pixels of the underlying device. When using native drawing technologies such as Quartz, UIKit, and Core Animation, the drawing coordinate space and the view’s coordinate space are both logical coordinate spaces, with distances measured in points. These logical coordinate systems are decoupled from the device coordinate space used by the system frameworks to manage the pixels onscreen.

    在iOS中,您在绘图代码中指定的坐标与底层设备的像素之间存在区别。 使用Quartz,UIKit和Core Animation等原生绘图技术时,绘图坐标空间和视图的坐标空间都是逻辑坐标空间,以点为单位测量距离。 这些逻辑坐标系与系统框架用于管理屏幕上像素的设备坐标空间分离。

    The system automatically maps points in the view’s coordinate space to pixels in the device coordinate space, but this mapping is not always one-to-one. This behavior leads to an important fact that you should always remember:

    系统会自动将视图坐标空间中的点映射到设备坐标空间中的像素,但此映射并不总是一对一的。 这种行为导致了一个重要的事实,你应该永远记住:

    One point does not necessarily correspond to one physical pixel.

    一点不一定对应于一个物理像素。

    The purpose of using points (and the logical coordinate system) is to provide a consistent size of output that is device independent. For most purposes, the actual size of a point is irrelevant. The goal of points is to provide a relatively consistent scale that you can use in your code to specify the size and position of views and rendered content. How points are actually mapped to pixels is a detail that is handled by the system frameworks. For example, on a device with a high-resolution screen, a line that is one point wide may actually result in a line that is two physical pixels wide. The result is that if you draw the same content on two similar devices, with only one of them having a high-resolution screen, the content appears to be about the same size on both devices.

    使用点(和逻辑坐标系)的目的是提供与设备无关的一致输出大小。 在大多数情况下,点的实际大小是无关紧要的。 点的目标是提供相对一致的比例,您可以在代码中使用该比例来指定视图和呈现内容的大小和位置。 实际如何将点映射到像素是由系统框架处理的细节。 例如,在具有高分辨率屏幕的设备上,一点宽的线实际上可能产生两个物理像素宽的线。 结果是,如果您在两个类似的设备上绘制相同的内容,其中只有一个具有高分辨率屏幕,则两个设备上的内容大小大致相同。

    Note: In the context of PDF rendering and printing, Core Graphics defines “point” using the industry standard mapping of one point to 1/72 of an inch.

    注意:在PDF渲染和打印的上下文中,Core Graphics使用一个点到1/72英寸的行业标准映射来定义“点”。

    In iOS, the UIScreen, UIView, UIImage, and CALayer classes provide properties to obtain (and, in some cases, set) a scale factor that describes the relationship between points and pixels for that particular object. For example, every UIKit view has a contentScaleFactor property. On a standard-resolution screen, the scale factor is typically 1.0. On a high-resolution screen, the scale factor is typically 2.0. In the future, other scale factors may also be possible. (In iOS prior to version 4, you should assume a scale factor of 1.0.)

    在iOS中,UIScreen,UIView,UIImage和CALayer类提供了获取(并且在某些情况下,设置)比例因子的属性,该比例因子描述了该特定对象的点和像素之间的关系。 例如,每个UIKit视图都有一个contentScaleFactor属性。 在标准分辨率屏幕上,比例因子通常为1.0。 在高分辨率屏幕上,比例因子通常为2.0。 将来,其他比例因子也是可能的。 (在版本4之前的iOS中,您应该假设比例因子为1.0。)

    Native drawing technologies, such as Core Graphics, take the current scale factor into account for you. For example, if one of your views implements a drawRect: method, UIKit automatically sets the scale factor for that view to the screen’s scale factor. In addition, UIKit automatically modifies the current transformation matrix of any graphics contexts used during drawing to take into account the view’s scale factor. Thus, any content you draw in your drawRect: method is scaled appropriately for the underlying device’s screen.

    原生绘图技术(如Core Graphics)会将当前比例因子考虑在内。 例如,如果您的一个视图实现了drawRect:方法,UIKit会自动将该视图的比例因子设置为屏幕的比例因子。 此外,UIKit会自动修改绘图期间使用的任何图形上下文的当前变换矩阵,以考虑视图的比例因子。 因此,您在drawRect:方法中绘制的任何内容都会针对底层设备的屏幕进行适当缩放。

    Because of this automatic mapping, when writing drawing code, pixels usually don’t matter. However, there are times when you might need to change your app’s drawing behavior depending on how points are mapped to pixels—to download higher-resolution images on devices with high-resolution screens or to avoid scaling artifacts when drawing on a low-resolution screen, for example.

    由于这种自动映射,在编写绘图代码时,像素通常无关紧要。 但是,有时您可能需要根据点映射到像素的方式更改应用程序的绘图行为 - 在具有高分辨率屏幕的设备上下载更高分辨率的图像,或者在低分辨率屏幕上绘图时避免缩放瑕疵 , 例如。

    In iOS, when you draw things onscreen, the graphics subsystem uses a technique called antialiasing to approximate a higher-resolution image on a lower-resolution screen. The best way to explain this technique is by example. When you draw a black vertical line on a solid white background, if that line falls exactly on a pixel, it appears as a series of black pixels in a field of white. If it appears exactly between two pixels, however, it appears as two grey pixels side-by-side, as shown in Figure 1-3.

    在iOS中,当您在屏幕上绘制内容时,图形子系统使用称为抗锯齿的技术来在较低分辨率的屏幕上逼近较高分辨率的图像。 解释这种技术的最好方法是举例。 当您在纯白色背景上绘制黑色垂直线时,如果该线恰好落在像素上,则它在白色区域中显示为一系列黑色像素。 但是,如果它恰好出现在两个像素之间,它会并排显示为两个灰色像素,如图1-3所示。

    Figure 1-3 A one-point line centered at a whole-numbered point value

    图1-3 以整数点值为中心的单点线
    在这里插入图片描述

    Positions defined by whole-numbered points fall at the midpoint between pixels. For example, if you draw a one-pixel-wide vertical line from (1.0, 1.0) to (1.0, 10.0), you get a fuzzy grey line. If you draw a two-pixel-wide line, you get a solid black line because it fully covers two pixels (one on either side of the specified point). As a rule, lines that are an odd number of physical pixels wide appear softer than lines with widths measured in even numbers of physical pixels unless you adjust their position to make them cover pixels fully.

    由整数点定义的位置落在像素之间的中点。 例如,如果从(1.0,1.0)到(1.0,10.0)绘制一个像素宽的垂直线,则会得到模糊的灰线。 如果绘制一条两像素宽的线,则会得到一条纯黑线,因为它完全覆盖两个像素(指定点两侧各一个)。 通常,奇数个物理像素宽的线条比使用偶数个物理像素测量宽度的线条更柔和,除非您调整它们的位置以使它们完全覆盖像素。

    Where the scale factor comes into play is when determining how many pixels are covered by a one-point-wide line.

    比例因子起作用的地方是确定一点宽线覆盖多少像素。

    On a low-resolution display (with a scale factor of 1.0), a one-point-wide line is one pixel wide. To avoid antialiasing when you draw a one-point-wide horizontal or vertical line, if the line is an odd number of pixels in width, you must offset the position by 0.5 points to either side of a whole-numbered position. If the line is an even number of points in width, to avoid a fuzzy line, you must not do so.

    在低分辨率显示器(比例因子为1.0)上,一点宽线是一个像素宽。 要在绘制一个点宽的水平或垂直线时避免抗锯齿,如果线宽为奇数个像素,则必须将位置偏移0.5个点到整个编号位置的任意一侧。 如果线宽为偶数个点,为避免模糊线,则不得这样做。

    Figure 1-4 Appearance of one-point-wide lines on standard and retina displays

    图1-4 标准和视网膜显示屏上一点宽线的外观

    在这里插入图片描述
    On a high-resolution display (with a scale factor of 2.0), a line that is one point wide is not antialiased at all because it occupies two full pixels (from -0.5 to +0.5). To draw a line that covers only a single physical pixel, you would need to make it 0.5 points in thickness and offset its position by 0.25 points. A comparison between the two types of screens is shown in Figure 1-4.

    在高分辨率显示器(比例因子为2.0)上,一点宽的线根本没有抗锯齿,因为它占据两个完整像素(从-0.5到+0.5)。 要绘制仅覆盖单个物理像素的线,您需要将其设置为0.5个点,并将其位置偏移0.25个点。 两种屏幕的比较如图1-4所示。

    Of course, changing drawing characteristics based on scale factor may have unexpected consequences. A 1-pixel-wide line might look nice on some devices but on a high-resolution device might be so thin that it is difficult to see clearly. It is up to you to determine whether to make such a change.

    当然,基于比例因子改变绘图特性可能会产生意想不到的后果。 1像素宽的线在某些设备上可能看起来不错,但在高分辨率设备上可能很薄,很难看清楚。 由您决定是否进行此类更改。

    展开全文
  • 原网址:https://code.tutsplus.com/tutorials/smooth-freehand-drawing-on-ios--mobile-13164 博客中中文转载地址(直接网页翻译的):http://blog.csdn.net/u013410274/article/details/78894440 整理的代码地址...
  • 遮罩,模糊和动画会为我们的APP增色不少,现在,就让我们了解一下吧。 用Blocks绘制Images 利用下面工具函数,可以简化创建image的过程。 ...typedef void(^DrawingStateBlock)();...UIImage * DrawIntoImage(CGSize ...
  •  从本节开始我们开始学习绘图相应技术,本节主要简单的介绍了IOS中的绘图和打印技术,用到的技术和如何进行。  转载请注明出处:http://blog.csdn.net/developer_zhang 2 详述  本覆盖了三个主题“ ·绘制自定义...
  • iOS Drawing Concepts https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html High-quality graphics are...
  • iOS Drawing-Images

    2018-04-26 18:58:19
    iOS Drawing-Images 内容来自[Addison.Wesley.IOS.Drawing.Sep.2014.ISBN.1502345307],记录下重要的内容 基本 创建context CGBitmapContextCreate()创建位图图形上下文(Creates a bitmap graphics context)...
  • ios开发资料大全

    2015-11-09 14:57:41
    Beginning iOS 7 Development Exploring the iOS SDK pdf 版本 : Apress.Beginning iOS 7 Development.Exploring the iOS SDK.2014.pdf.part1.rar (9.54 MB, 下载次数: 7307) 2014-5-28 04:23 上传 ...
  • My Palette介绍: 一个简单的画图...http://ios.itmdc.com/thread-160-1-1.html简单绘画介绍: 简单的绘制直线,矩形,文字等。http://ios.itmdc.com/thread-160-1-1.html小画板介绍: 利用cocos2d来实现一个画板功...
  • About Drawing and Printing in iOS --关于iOS中的绘图和打印 This document covers three related subjects: --该文档覆盖了三个主题: Drawing custom UI views. Custom UI views allow you to draw ...
  • 苹果公司的iOS平台强力推动了iOS开发,引来了不少人从事iOS开发,也成就了一批一批的开发者,如果你是新手,请把本文作为iOS技术一览,便于你对iOS开发有个粗略的认识;如果你已经是iOS开发者,建议你收藏本文,它是...
  • iOS Drawing Performance

    2016-03-04 10:19:49
    唤醒Instruments:记住要使用iOS真机测试Product菜单 -> Profile选项2.我们通常对Instruments的某些工具感兴趣: Time Profile:测量CPU用法 Core Animation:调试各种类型的Core Animation性能问题 GPU Driver:...
  • iOS Drawing Concepts

    2013-10-25 16:33:42
    iOS Drawing Concepts https://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/graphicsdrawingoverview/graphicsdrawingoverview.html iOS Drawing Concep
  • 今天我们来学习一下IOS中的绘图模型。 2 详述 IOS和OS X中的绘图模型遵循两种技术途径中的其中一种,基于一种根据要求更新外观的模式。  ·OpenGL:OpenGL是一个为了在台式机创建2D和3D内容的基于C语言的接口。他是...
  • 前言 电子签名
  • Programming iOS 9: Dive Deep into Views, View Controllers, and Frameworks Covers iOS9, XCode7 and Swift 2 2015.12.3即将出版的新书 Paperback: 1048 pages Publisher: O'Reilly Media; 1 edition (December 3...
  • #import #import @interface DrawLine : NSObject ...+ (void)drawCenter:(UIImageView *)imageView withBeginX:(CGFloat)Bx withBeginY:(CGFloat)By ... withEndX:(CGFloat)Ex withEndY:(C
  • IOS Drawing 1

    2019-07-27 09:54:18
    ios中,有两种基本的drawing技术。一种就是使用原生的drawing技术。此技术包括Core Graphics和UIKit框架,支持2D drawing。另一种就是使用OpenGL ES,此支持2D和3D。 1. Quartz在IOS中是native window server和...
1 2 3 4 5 ... 20
收藏数 7,594
精华内容 3,037
关键字:

drawing ios