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
48
49
50
51
52
53
54
55
56
57
58
//
// KWMFirstView.m
// iCemarose
//
// Created by 陈荣科 on 16/8/25.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMFirstView.h"
@implementation KWMFirstView
- (void)awakeFromNib{
[super awakeFromNib];
[self.ivCoin1.layer addAnimation:[self opacityForever_Animation:0.7 WithTag:1] forKey:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.9 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.ivCoin2.layer addAnimation:[self opacityForever_Animation:0.7 WithTag:2] forKey:nil];
});
}
- (void)layoutSubviews{
CGFloat coin2Y = UI_SCREEN_HEITHT*0.4737f;
CGFloat coin2X = UI_SCREEN_WIDTH*0.0666f;
CGFloat coin2W = UI_SCREEN_WIDTH*0.256f;
CGFloat coin2H = UI_SCREEN_HEITHT*0.0659f;
self.coinWidth2.constant = coin2W;
self.coinHeight2.constant = coin2H;
self.marginTop2.constant = coin2Y;
self.marginLeft1.constant = coin2X;
CGFloat coin1Y = UI_SCREEN_HEITHT*0.46476f;
CGFloat coin1X = UI_SCREEN_WIDTH*0.5253f;
CGFloat coni1W = UI_SCREEN_WIDTH*0.224f;
CGFloat coin1H = UI_SCREEN_HEITHT*0.0719f;
self.coinWidth1.constant = coni1W;
self.coinHeight1.constant = coin1H;
self.marginTop1.constant = coin1Y;
self.marginLeft1.constant = coin1X;
}
-(CABasicAnimation *)opacityForever_Animation:(float)time WithTag:(NSInteger)tag
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];//必须写opacity才行。
animation.fromValue = [NSNumber numberWithFloat:0.2f];
animation.toValue = [NSNumber numberWithFloat:1.0f];//这是透明度。
animation.autoreverses = YES;
animation.duration = time;
animation.repeatCount = MAXFLOAT;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];//没有的话是均匀的动画。
return animation;
}
@end