Last active
December 7, 2018 04:02
-
-
Save baobao/d88746021b8417b652cd to your computer and use it in GitHub Desktop.
CoreAnimationの勉強。
Flashのような描画テスト。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//layer生成 | |
CALayer *layer = [CALayer layer]; | |
layer.frame = CGRectMake(0, 0, 20, 20); | |
layer.backgroundColor = [[UIColor redColor] CGColor]; | |
//layer設定 | |
layer.position = CGPointMake(100, 200); | |
//枠線カラー | |
layer.borderColor =[UIColor blueColor].CGColor; | |
//枠線の太さ | |
layer.borderWidth = 10; | |
//addChild | |
[self.view.layer addSublayer:layer]; | |
//透明度 | |
layer.opacity = 0.5; | |
//ドロップシャドウの設定 | |
layer.shadowOpacity = 0.8; | |
//影の形 | |
layer.shadowPath = [UIBezierPath bezierPathWithRect:layer.bounds].CGPath; | |
//ぼかしの大きさ | |
layer.shadowRadius = 10; | |
//offset | |
layer.shadowOffset = CGSizeMake(4, 4); | |
//影の色 | |
layer.shadowColor = [UIColor blackColor].CGColor; | |
CGMutablePathRef path = CGPathCreateMutable(); | |
//パスの最初のポイントをセット | |
CGPathMoveToPoint(path, NULL, 74, 74); | |
//座標を追加 | |
CGPathAddCurveToPoint(path, NULL, | |
74, 200, | |
100, 200, | |
200, 420); | |
//座標を追加 | |
CGPathAddCurveToPoint(path, NULL, 320, 0, 100, 100, 6, 74); | |
//アニメーションインスタンスを生成 | |
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; | |
//2秒かける | |
animation.duration = 2.0f; | |
//アニメーションパスを設定 | |
animation.path = path; | |
//リピート | |
animation.repeatCount = NSUIntegerMax; | |
//動きをリバース | |
animation.autoreverses = YES; | |
//イージング | |
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
//アニメーション開始 | |
[layer addAnimation:animation forKey:@"aaa"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ドロップシャドウを追加