1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// 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