先上效果图: CALayer系列.gif CGContextRef、UIBezierPath、文本属性Attributes.gif 一、CAEmitterLayer 粒子属性 //设置发射器 CAEmitterLayer...设置文本附件,取值为NSTextAttachment对象,常用于文字图片混排 */ 还有CAReplicatorLayer、CAShapeLayer、CATextLayer、CGContextRef
CGContextGetCTM(CGContextRef cg_nullable c); //设置绘制的线宽 void CGContextSetLineWidth(CGContextRef cg_nullable...(CGContextRef cg_nullable c, CGFloat alpha); //设置图像复合模式 void CGContextSetBlendMode(CGContextRef cg_nullable...(CGContextRef cg_nullable c); //进行图形上下文的拷贝 CGPathRef __nullable CGContextCopyPath(CGContextRef cg_nullable...(CGContextRef cg_nullable c); //填充某个矩形区域 void CGContextFillRect(CGContextRef cg_nullable c, CGRect rect...(CGContextRef cg_nullable c, CGRect rect); //进行虚线区域边框的绘制 void CGContextStrokeEllipseInRect(CGContextRef
c, CGFloat x, CGFloat y) //添加新的线段到某个点 void CGContextAddLineToPoint(CGContextRef c, CGFloat x, CGFloat...(CGContextRef context, CGRect rect) //添加一个圆弧 void CGContextAddArc(CGContextRef c, CGFloat x, CGFloat...(CGContextRef c) //提示:一般以CGContextDraw、CGContextStroke、CGContextFill开头的函数,都是用来绘制路径的 图形上下文栈的操作 //将当前的上下文...(CGContextRef c) 矩阵操作 利用矩阵操作,能让绘制到上下文中的所有路径一起发生变化 //缩放 void CGContextScaleCTM(CGContextRef c, CGFloat...(CGContextRef c, CGFloat tx, CGFloat ty) Quartz2D的内存管理 使用含有“Create”或“Copy”的函数创建的对象,使用完后必须释放,否则将导致内存泄露
如下代码演示了在自定义View的drawRect:方法中进行PDF文档的绘制: -(void)drawRect:(CGRect)rect{ //由于坐标系不同,需要进行翻转 CGContextRef...在创建PDF文档时,开发者还可以使用如下列举的方法来对文档进行超链接添加,内容信息设置等: //关闭文档上下文,关闭后将不能再次写入 void CGPDFContextClose(CGContextRef...__nullable pageInfo); //结束当前页内容的绘制 void CGPDFContextEndPage(CGContextRef cg_nullable context); //添加元数据...void CGPDFContextAddDocumentMetadata(CGContextRef cg_nullable context, CFDataRef __nullable metadata...); //为某个区域添加超链接 void CGPDFContextSetURLForRect(CGContextRef cg_nullable context, CFURLRef url, CGRect
重绘的时候:调用view的setNeedsDisplay或者setNeedsDisplayInRect:时 1.3 Graphics Context Graphics Context 是一个数据类型(CGContextRef...CGContextRef 对应绘画者模式中的 Page。 当用 Quartz 绘图时,所有设备相关的特性都包含在Graphics Context 中。...drawRect:(CGRect)rect中的rect指的就是绘图view的bounds - (void)drawRect:(CGRect)rect { //1.获取图形上下文对象 CGContextRef...绘制基本图形 好了,坐好了,老司机开始开车啦~ 2.1 绘制三角形 - (void)drawRect:(CGRect)rect { // 获取context CGContextRef ctx...- (void)drawRect:(CGRect)rect { // 获取context CGContextRef ctx = UIGraphicsGetCurrentContext();
)drawRect:(CGRect)rect方法 -(void)drawRect:(CGRect)rect{ [super drawRect:rect]; //获取ctx CGContextRef...//画线 -(void)drawLine:(CGContextRef)ctx{ //画一条简单的线 CGPoint points1[] = {CGPointMake...//描出笔触 CGContextStrokePath(ctx); } 画矩形、椭圆形、多边形 //画矩形,画椭圆,多边形 -(void)drawSharp:(CGContextRef...[image drawInRect:CGRectMake(10, 300, 100, 100)];//在坐标中画出图片 } 画文字 //画文字 -(void)drawText:(CGContextRef...; //三次曲线函数 //void CGContextAddCurveToPoint ( // CGContextRef
// 绘制直线 + (void)toDrawLineFromX:(CGFloat)x1 Y:(CGFloat)y1 toX:(CGFloat)x2 toY:(CGFloat)y2 context:(CGContextRef...CGContextStrokePath(con); } 绘制矩形 //绘制矩形 ,fillColor填充色 + (void)toDrawRect:(CGRect)rectangle color:fillColor context:(CGContextRef...绘制文字,rect1指定矩形,绘制文字在这个矩形水平和垂直居中 + (void)toDrawTextWithRect:(CGRect)rect1 str:(NSString*)str1 context:(CGContextRef...drawLine(x1,y1,x2,y2,con) [DrawUtil toDrawLineFromX:x1 Y:y1 toX:x2 toY:y2 context:con] //获得上下文 CGContextRef
该框架可以用于基于路径的绘图、变换、颜色管理、脱屏渲染,模板、渐变、遮蔽、图像数据管理、图像的创建、遮罩以及PDF文档的创建、显示和分析 Graphics Context Graphics Context是一个数据类型(CGContextRef...} 2、UIView+drawRect+context 获取到drawRect自动生成的context,在context里画图形 - (void)drawRect:(CGRect)rect{ CGContextRef...inContext: 注意要显式调用[view.layer setNeedsDisplay]这个方法才起作用 - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef...orangeColor].CGColor); CGContextFillPath(ctx); } 或者 - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef...- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{ UIGraphicsPushContext(ctx); UIBezierPath
130, 230) radius:70 startAngle:0 endAngle:M_PI clockwise:YES]; [path4 stroke]; // 1.获得当前上下文 CGContextRef...ctx, M_PI_4); //缩放 CGContextScaleCTM(ctx, 1.2, 1.2); 上下文栈 先保存或者还原上下文栈,再设置状态 // 1.获得当前上下文 CGContextRef...UIGraphicsEndImageContext(); 截图 给定裁减区域再渲染 //开启图片上下文 UIGraphicsBeginImageContext(view.frame.size); //获得当前上下文 CGContextRef...开启上下文 UIGraphicsBeginImageContextWithOptions(self.imageView.frame.size, NO, 0); //获得当前上下文 CGContextRef
static CGContextRef CreateRGBABitmapContext (CGImageRef inImage) { CGContextRef context = NULL;...{ CGImageRef img = [inImage CGImage]; CGSize size = [inImage size]; //使用上面的函数创建上下文 CGContextRef...else { width_ = 70; } UIGraphicsBeginImageContext(CGSizeMake(width_, width_)); CGContextRef
其实,ios中大部分控件的内容都是通过Quart2D画出来的 4、图形上下文(GraphicsContext): 是一个CGContextRef类型的数据 图形上下文的作用:1)保存绘制信息、...(CGContextRef context, CGRect rect) 5)添加一个圆弧:void CGContextAddArc(CGContextRef c, CGFloat x, CGFloat... CGContextFillPath(CGContextRef c) 一般以CGContextDraw、CGContextStroke、CGContextFill开头的函数,都是用来绘制路径的... 9)将当前的上下文 Copy一份,保存到栈顶(那个栈叫做图形上下文栈): void CGContextSaveGState(CGContextRef c) 10)将栈顶的上下文出栈...,替换掉当前的上下文: void CGContextRestoreGState(CGContextRef c) 9 、 示例代码 效果截图 ?
convolution %ld", error); } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef...UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); CGContextRef...UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); CGContextRef...用于输出图像 UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); CGContextRef
进行图像截取的示例代码如下: -(void)drawRect:(CGRect)rect{ CGContextRef contextRef = UIGraphicsGetCurrentContext...代码如下: -(void)drawRect:(CGRect)rect{ CGContextRef contextRef = UIGraphicsGetCurrentContext();...示例代码如下: -(void)drawRect:(CGRect)rect{ CGContextRef contextRef = UIGraphicsGetCurrentContext();...除了上面介绍了两种对图像进行裁剪的方法外,CoreGraphics框架中还提供了一种裁剪方式,示例代码如下: -(void)drawRect:(CGRect)rect{ CGContextRef...示例代码如下: -(void)drawRect:(CGRect)rect{ CGContextRef contextRef = UIGraphicsGetCurrentContext();
水波.gif 上面的效果主要用到了CALayer的一些子类,CGConTextRef ,贝塞尔曲线和CADisplayLink等 。。。 Demo里封装好的,可以直接拿来用!...CADisplayLink结合UIBezierPath的神奇妙用 http://www.jianshu.com/p/c35a81c3b9eb Core Animation系列之CADisplayLink IOS用CGContextRef
subjectButtonpointInside:buttonPointwithEvent:event]){ return_subjectButton; } returnresult; } 3.3参考链接 CGContextRef...article/details/8730352 iOS重绘机制drawRect http://blog.csdn.net/fww330666557/article/details/8647608 iOS CGContextRef...画图小结 http://blog.sina.com.cn/s/blog_9693f61a0101deko.html iOS使用CGContextRef绘制各种图形 http://www.devstore.cn.../essay/essayInfo/116.html (good)IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片) http:/
Quartz2D的API来自于Core Graphics框架,数据类型和函数基本都以CG作为前缀:CGContextRef、CGPathRef等。...Graphics Context Quartz2D绘图的基本步骤 获得图形上下文 拼接路径(下面代码是搞一条线段,添加矩形、椭圆、圆弧的代码可以查看具体的APi,用法基本相同) 绘制路径 代码示例: CGContextRef...CGContextFillPath(ctx); 图形上下文栈的操作 将当前的上下文copy一份,保存到栈顶(那个栈叫做”图形上下文栈”,先进后出) void CGContextSaveGState(CGContextRef...c) 将栈顶的上下文出栈,替换掉当前的上下文 void CGContextRestoreGState(CGContextRef c) Quartz2D的内存管理 使用含有“Create”或“Copy”...获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); 2.
captureView:(UIView *)theView { CGRect rect = theView.frame; UIGraphicsBeginImageContext(rect.size); CGContextRef...captureView: (UIView *)theView { CGRect rect = theView.frame; UIGraphicsBeginImageContext(rect.size); CGContextRef...不过好像还不支持ios) 下面给出一个在ios上反色的例子 -(id)invertContrast:(UIImage*)img { CGImageRef inImage = img.CGImage; CGContextRef...(显示图像数据区,也就是unsigned char*转为graphics context或者UIImage或和CGImageRef) CGContextRef ctx = CGBitmapContextCreate
imageBytes imageSize:(CGSize)imageSize { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef...image.size.width *image.size.height *4); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef
CGGradientCreateWithColorComponents (colorSpaceRef, colors, locs, 2); CGContextRef...kCGGradientDrawsAfterEndLocation = (1 << 1) //终点之后也进行填充 }; */ CG_EXTERN void CGContextDrawRadialGradient(CGContextRef...func, false, false); CGContextRef...CGGradientCreateWithColorComponents (colorSpaceRef, colors, locs, 2); CGContextRef...CGGradientCreateWithColorComponents (colorSpaceRef, colors, locs, 8); CGContextRef
rect.size.width/2, rect.size.height/2); CGSize myShadowOffset = CGSizeMake (10, -20); CGContextRef...rect.size.width/2, rect.size.height/2); CGSize myShadowOffset = CGSizeMake (10, -20); CGContextRef
领取专属 10元无门槛券
手把手带您无忧上云