摘要: 1 UIImage *image = [UIImage imageNamed:@"heart.png"]; 2 CALayer *layer = [CALayer layer]; 3 layer.contents = (id)image.CGImage; 4 layer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); 5 layer.position = CGPointMake(160, 200); 6 7 layer.transform = CATransfor... 阅读全文
posted @ 2013-02-08 22:25 diablo大王 阅读(326) 评论(0) 推荐(0) 编辑
摘要: CAGradientLayer可以方便的处理颜色渐变。 1 self.view.backgroundColor = [UIColor whiteColor]; 2 UIImage *image = [UIImage imageNamed:@"mountains.png"]; // 原图 3 4 CALayer *imageLayer = [CALayer layer]; 5 imageLayer.borderColor = [UIColor greenColor].CGColor; 6 imageLayer.borderWidth = 2; 7 ... 阅读全文
posted @ 2013-02-08 22:12 diablo大王 阅读(1733) 评论(0) 推荐(0) 编辑
摘要: 1 CALayer *layer = [[self.view.layer sublayers] objectAtIndex:0]; layer.shadowPath = (layer.shadowPath) ? nil : [self bezierPathWithCurvedShadowForRect:layer.bounds2 ].CGPath; 1 static const CGFloat offset = 10.0; 2 static const CGFloat curve = 5.0; 3 - (UIBezierPath*)bezierPathWithCurvedSh... 阅读全文
posted @ 2013-02-08 21:00 diablo大王 阅读(526) 评论(0) 推荐(0) 编辑
摘要: 1.shadowPath: 设置 CALayer 背景(shodow)的位置2.shadowOffset: shadow 在 X 和 Y 轴 上延伸的方向,即 shadow 的大小3.shadowOpacity : shadow 的透明效果4.shadowRadius: shadow 的渐变距离,从外围开始,往里渐变 shadowRadius 距离5.masksToBounds : 很重要的属性,可以用此属性来防止子元素大小溢出父元素,如若防止溢出,请设为 true6. borderWidth 和 boarderColor : 边框颜色和宽度,很常用7.bounds: 大小,与position 阅读全文
posted @ 2013-02-08 20:57 diablo大王 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 1 CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];2 transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];3 transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(DEGREES_TO_RADIAN.. 阅读全文
posted @ 2013-02-08 20:08 diablo大王 阅读(1646) 评论(0) 推荐(0) 编辑
摘要: { NSLog(@"111"); SEL rl = @selector(rotateLayers); [selfperformSelector:rl withObject:nilafterDelay:1.0];// 这里不延时1秒 NSLog(@"222");}- (void)rotateLayers { NSLog(@"333");}结果:19:47:55.326 CA Demos[5138:907] 11119:47:55.327 CA Demos[5138:907] 22219:47:56.329 CA Demos[5138:9 阅读全文
posted @ 2013-02-08 19:52 diablo大王 阅读(2306) 评论(0) 推荐(0) 编辑
摘要: 1 CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 2 rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 3]; 3 rotationAnimation.duration = 1.9f; 4 rotationAnimation.timingFunction = [CAMediaTimingFunction function... 阅读全文
posted @ 2013-02-08 19:41 diablo大王 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 1 UIBezierPath *path = [UIBezierPath bezierPath]; 2 [path moveToPoint:CGPointMake(-40, 100)]; 3 [path addLineToPoint:CGPointMake(360, 100)]; 4 [path addLineToPoint:CGPointMake(360, 200)]; 5 [path addLineToPoint:CGPointMake(-40, 200)]; 6 [path addLineToPoint:CGPointMake(-40, ... 阅读全文
posted @ 2013-02-08 10:51 diablo大王 阅读(3387) 评论(0) 推荐(0) 编辑
摘要: 1 rotationAnimation.removedOnCompletion = NO;2 3 rotationAnimation.fillMode = kCAFillModeForwards;fillMode的作用就是决定当前对象过了非active时间段的行为. 比如动画开始之前,动画结束之后。如果是一个动画CAAnimation,则需要将其removedOnCompletion设置为NO,要不然fillMode不起作用. 下面来讲各个fillMode的意义kCAFillModeRemoved这个是默认值,也就是说当动画开始前和动画结束后,动画对layer都没有影响,动画结束后,layer 阅读全文
posted @ 2013-02-08 10:24 diablo大王 阅读(12207) 评论(1) 推荐(1) 编辑