// // KWMThreeView.m // iCemarose // // Created by 陈荣科 on 16/8/25. // Copyright © 2016年 kollway. All rights reserved. // #import "KWMThreeView.h" @implementation KWMThreeView - (void)awakeFromNib{ [super awakeFromNib]; [self.ivPlane.layer addAnimation:[self moveTime:1 ToY:[NSNumber numberWithInt:15]] forKey:nil]; } - (void)layoutSubviews{ CGFloat planeY = UI_SCREEN_HEITHT*0.2818f; CGFloat planeX = UI_SCREEN_WIDTH*0.1973f; CGFloat planeWidth = UI_SCREEN_WIDTH*0.6053f; CGFloat planeHeight = UI_SCREEN_HEITHT*0.2189f; self.planeWidth.constant = planeWidth; self.planeHeight.constant = planeHeight; self.marginTop.constant = planeY; self.marginLeft.constant = planeX; } #pragma mark ===== 横向、纵向移动 =========== -(CABasicAnimation*)moveTime:(CGFloat)time ToY:(NSNumber *)Y { CABasicAnimation *animationY = [ CABasicAnimation animationWithKeyPath : @"transform.translation.y" ]; //x 的话就向下移动。 animationY.toValue = Y; animationY.duration = time; animationY.removedOnCompletion = NO ;//yes 的话,又返回原位置了。 animationY.autoreverses = YES; animationY.repeatCount = MAXFLOAT; animationY.fillMode = kCAFillModeBackwards; animationY.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; return animationY; } @end