GrounderSuperView.m
2.18 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// GrounderSuperView.m
// GrounderDemo
//
// Created by 贾楠 on 16/3/10.
// Copyright © 2016年 贾楠. All rights reserved.
//
#import "GrounderSuperView.h"
#import "GrounderView.h"
@interface GrounderSuperView()
{
NSMutableArray *grounderArray;
NSMutableArray *modelArray;
NSInteger grounderCount;
}
@end
@implementation GrounderSuperView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
grounderArray = [[NSMutableArray alloc] init];
modelArray = [[NSMutableArray alloc] init];
grounderCount = 0;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nextView:) name:@"nextView" object:nil];
for (int i = 0; i < 4; i++) {
GrounderView *grounder = [[GrounderView alloc] init];
grounder.isShow = NO;
grounder.index = i;
[grounderArray addObject:grounder];
}
}
return self;
}
- (void)setModel:(id)model{
[modelArray addObject:model];
[self checkView];
}
- (void)nextView:(NSNotification *)notification{
[self checkView];
}
- (void)checkView{
if (modelArray.count == 0) {
return;
}
__weak GrounderSuperView *this = self;
dispatch_async(dispatch_get_main_queue(), ^{
for (GrounderView *view in grounderArray) {
if (view.isShow == NO) {
switch (view.index) {
case 0:
view.selfYposition = 105;
break;
case 1:
view.selfYposition = 70;
break;
case 2:
view.selfYposition = 35;
break;
case 3:
view.selfYposition = 0;
break;
default:
break;
}
view.isShow = YES;
[view setContent:modelArray[0]];
[this addSubview:view];
[view grounderAnimation:modelArray[0]];
[modelArray removeObjectAtIndex:0];
break;
}
}
});
}
@end