_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
サンプル(回転系)
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (void)startUpdateAnimation
{
#if TRUE
CABasicAnimation *animationX = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animationX.toValue = [NSNumber numberWithFloat:0.5f * M_PI];
// アニメーション処理
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 0.2f;
group.repeatCount = 1;
group.autoreverses = YES;
// アニメーション終了時に元に戻さないようにする
group.removedOnCompletion = NO;
group.fillMode = kCAFillModeForwards;
group.animations = [NSArray arrayWithObjects:animationX, nil];
[self.layer addAnimation:group forKey:@"rotateX-layer"];
#else
CABasicAnimation *animationX = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animationX.toValue = [NSNumber numberWithFloat:0.5f * M_PI];
CABasicAnimation *animationY = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
animationY.toValue = [NSNumber numberWithFloat:0.5f * M_PI];
CABasicAnimation *animationZ = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animationZ.toValue = [NSNumber numberWithFloat:0.5f * M_PI];
// アニメーション処理
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 0.2f;
group.repeatCount = 1; // HUGE_VALF
group.autoreverses = YES;
group.animations = [NSArray arrayWithObjects:animationX, animationY, animationZ, nil];
[self.layer addAnimation:group forKey:@"rotateX-layer"];
#endif
}
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
パラメータ
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
<UIViewAnimationCurve>
UIViewAnimationCurveEaseInOut ゆっくり始まって徐々に加速し、中盤から減速
UIViewAnimationCurveEaseIn ゆっくり始まり、徐々に加速
UIViewAnimationCurveEaseOut 速く始まり、徐々に減速
UIViewAnimationCurveLinear 等速度
<IViewAnimationTransition>
UIViewAnimationTransitionNone 指定無し
UIViewAnimationTransitionFlipFromLeft 中央の垂直軸中心に右回転で遷移
UIViewAnimationTransitionFlipFromRight 中央の垂直軸中心に左回転で遷移
UIViewAnimationTransitionCurlUp 下から上にカールして遷移
UIViewAnimationTransitionCurlDown 上から下にカールして遷移
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
アニメーション停止
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[view.layer removeAllAnimations];
view.transform = CGAffineTransformMakeScale(1.0, 1.0);
view.transform = CGAffineTransformIdentity;
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
アニメーション(その1)
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
typeof(self) __weak wself = self;
[UIView animateWithDuration:0.5f
delay:0.0f
options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
}
completion:^(BOOL finished) {
}];
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
アニメーション(その2)
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[UIView transitionWithView:view duration:0.5f
options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionCurveEaseInOut
animations:^{
view.alpha = 1.0f;
view.transform = CGAffineTransformIdentity;
}
completion:^(BOOL finished) {
}];
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
点滅表示
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (void)blinkImage:(UIImageView *)target
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration = 0.1f;
animation.autoreverses = YES;
animation.repeatCount = 3; //infinite loop -> HUGE_VAL
animation.fromValue = [NSNumber numberWithFloat:1.0f]; //MAX opacity
animation.toValue = [NSNumber numberWithFloat:0.0f]; //MIN opacity
[target.layer addAnimation:animation forKey:@"blink"];
}
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
消去
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration = 1.0f;
animation.autoreverses = NO;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.fromValue = [NSNumber numberWithFloat:1.0f];
animation.toValue = [NSNumber numberWithFloat:0.0f];
[targetView.layer addAnimation:animation forKey:@"crossDissolve"];
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
以下、参照用とする
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
BOOL isSlided = (!(isExistElvImgNo || isExistWallImgNo1));
typeof(self) __weak wself = self;
[UIView animateWithDuration:0.4f
delay:0.0f
options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
wself.imageView.alpha = (isSlided)? 0.0f: 1.0f;
CGRect frame = wself.slideView.frame;
CGFloat x = (isSlided)? 50: 200;
frame.origin.x = x;
wself.slideView.frame = frame;
}
completion:^(BOOL finished) {
}];
最終更新:2017年04月03日 13:34