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
45
46
47
//
// KWMSecondView.m
// iCemarose
//
// Created by 陈荣科 on 16/8/25.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMSecondView.h"
#import "KWMImageUtil.h"
@implementation KWMSecondView
- (void)awakeFromNib{
[super awakeFromNib];
//2 15
[self.ivPhoto.layer addAnimation:[self moveTime:1 ToY:[NSNumber numberWithInt:15]] forKey:nil];
}
- (void)layoutSubviews{
CGFloat photoY = UI_SCREEN_HEITHT*0.0810f;
CGFloat photoX = UI_SCREEN_WIDTH*0.216f;
CGFloat photoW = UI_SCREEN_WIDTH*0.5706f;
CGFloat photoH = UI_SCREEN_HEITHT*0.5292f;
self.ivWidth.constant = photoW;
self.ivHeight.constant = photoH;
self.marginTop.constant = photoY;
self.marginLeft.constant = photoX;
}
#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