随笔分类 -  Quartz Core 图层编程

摘要:CAGradientLayer可以方便的处理颜色渐变。Properties:@property(copy)NSArray*colors渐变颜色的数组[cpp]view plaincopy[NSArrayarrayWithObjects:(id)[[[UIColorblackColor]colorWithAlphaComponent:1]CGColor],(id)[[[UIColoryellowColor]colorWithAlphaComponent:1]CGColor],(id)[[[UIColorblueColor]colorWithAlphaComponent:1]CGColor],(i 阅读全文
posted @ 2013-02-02 11:14 高笑228 阅读(496) 评论(0) 推荐(0)
摘要:CALayer(层)是屏幕上的一个矩形区域,在每一个UIView中都包含一个根CALayer,在UIView上的所有视觉效果都是在这个Layer上进行的。CALayer外形特征主要包括:1、层的大小尺寸2、背景色3、内容(可以填充图片或者使用Core Graphics绘制的内容)4、矩形是否使用圆角5、矩形是否有阴影Layer有很多种,最常用也是最基本的是CALayer,当然还包括其他的子类:CAScrollerLayer 简化显示层的一部分CATextLayer 文本层CAGradientLayer、CAShapeLayer等等使用层之前,需要在项目中引入QuartzCore.framewo 阅读全文
posted @ 2013-02-02 10:53 高笑228 阅读(397) 评论(0) 推荐(0)
摘要:CAKeyframeAnimation *Animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; Animation.duration = 2; Animation.path = thePath.CGPath; Animation.calculationMode = kCAAnimationPaced; Animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaT... 阅读全文
posted @ 2013-01-29 15:15 高笑228 阅读(340) 评论(0) 推荐(0)
摘要:转自 http://alldunne.org/2011/09/how-to-pause-or-end-a-uiview-animation-via-the-calayer/-(void)pauseLayer:(CALayer*)layer{ CFTimeInterval paused_time = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = paused_time; }-(void)resumeLayer:(CALayer*)layer{ ... 阅读全文
posted @ 2013-01-28 17:27 高笑228 阅读(226) 评论(0) 推荐(0)
摘要:画虚线需要用到函数:CGContextSetLineDash此函数需要四个参数:context– 这个不用多说phase- 稍后再说lengths– 指明虚线是如何交替绘制,具体看例子count–lengths数组的长度[cpp] view plaincopyprint?CGContextRefcontext=UIGraphicsGetCurrentContext();CGContextBeginPath(context);CGContextSetLineWidth(context,2.0);CGContextSetStrokeColorWithColor(context,[UIColorwh 阅读全文
posted @ 2012-12-04 11:02 高笑228 阅读(538) 评论(0) 推荐(0)
摘要:在程序中如何把两张图片合成为一张图片- (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2 {UIGraphicsBeginImageContext(image1.size);// Draw image1[image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];// Draw image2[image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.hei 阅读全文
posted @ 2012-07-09 11:00 高笑228 阅读(405) 评论(0) 推荐(0)
摘要:一、添加 Quartz Core 框架要使用 Quartz Core 框架,你需要将其添加到你的工程中 。 然后 #import <Quartz Core/QuartzCore.h> 二、认识图层对 ps 有所了解的人都知道图层的概念,在这里也一样。在PS中一张图片至少得有一个图层,一个或多个图层的叠加构成了一张位图。我们这里一个或多个图层的叠加的构成了UIView(或其派生类)对象。看过我关于 UIView 文章的人可能会有疑问:UIView 和图层没啥区别啊?NO,还是有区别的,图层是有弹性的,你可以操纵图层,使 UIView 有各种效果,比如三维效果,形变等等。要访问一个图层 阅读全文
posted @ 2012-05-04 22:57 高笑228 阅读(580) 评论(0) 推荐(0)
摘要:iphone 中2d的仿射变换共有3种形式:1.Translate 位移对应方法有:CGAffineTransform CGAffineTransformTranslate(CGAffineTransform t, CGFloat tx, CGFloat ty);CGAffineTransform CGAffineTransformMakeTranslation(CGFloat tx, CGFloat ty);注:t 代表相对变换,tx,ty 代表相对位移2.Scale 缩放对应方法有:CGAffineTransform CGAffineTransformScale(CGAffineTran. 阅读全文
posted @ 2012-05-04 21:49 高笑228 阅读(604) 评论(0) 推荐(0)