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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// ReadPacketStateViewController.m
// Lighting
//
// Created by 曹云霄 on 2017/3/17.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import "ReadPacketStateViewController.h"
#import "ReadPacketViewController.h"
@interface ReadPacketStateViewController ()
@property (nonatomic,strong) UIViewController *currentVC;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *instructionViewConstraint;
@end
@implementation ReadPacketStateViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addChildViewController];
}
#pragma mark - 添加卡劵详情vc
- (void)addChildViewController
{
/// 未审核
ReadPacketViewController *unauditedVc = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"ReadPacketViewController"];
[self addChildViewController:unauditedVc];
unauditedVc.readPacketState = STUDYTASKSTATE_INITIAL;
[self.controllerBackgroundView addSubview:unauditedVc.view];
/// 已拒绝
ReadPacketViewController *refuseVc = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"ReadPacketViewController"];
refuseVc.readPacketState = STUDYTASKSTATE_REFUSE;
[self addChildViewController:refuseVc];
/// 已审核
ReadPacketViewController *auditedVc = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"ReadPacketViewController"];
auditedVc.readPacketState = STUDYTASKSTATE_USED;
[self addChildViewController:auditedVc];
self.currentVC = unauditedVc;
}
#pragma mark - 布局
- (void)viewDidLayoutSubviews
{
ReadPacketViewController *unauditedVc = self.childViewControllers[0];
unauditedVc.view.frame = CGRectMake(0, 0, self.controllerBackgroundView.mj_w, self.controllerBackgroundView.mj_h);
ReadPacketViewController *refuseVc = self.childViewControllers[1];
refuseVc.view.frame = CGRectMake(0, 0, self.controllerBackgroundView.mj_w, self.controllerBackgroundView.mj_h);
ReadPacketViewController *auditedVc = self.childViewControllers[2];
auditedVc.view.frame = CGRectMake(0, 0, self.controllerBackgroundView.mj_w, self.controllerBackgroundView.mj_h);
}
#pragma mark - 切换
- (void)switchPaymentsVCAndWithdrawalVC:(UIViewController *)newViewController
{
[self transitionFromViewController:self.currentVC toViewController:newViewController duration:0.5 options:UIViewAnimationOptionTransitionNone animations:nil completion:^(BOOL finished) {
if (finished) {
[self.controllerBackgroundView addSubview:newViewController.view];
self.currentVC = newViewController;
}
}];
}
#pragma mark - 设置指示线的位置
- (void)setupInstructionsViewOrigin:(UIButton *)sender
{
self.instructionViewConstraint.constant = sender.x+16;
[UIView animateWithDuration:0.5 delay:0.1f usingSpringWithDamping:0.5f initialSpringVelocity:0.5f options:UIViewAnimationOptionCurveEaseInOut animations:^{
[self.view layoutIfNeeded];
} completion:nil];
}
#pragma mark - 切换ContentController
#pragma mark -红包状态 tag 100表示未审核,101表示已拒绝,102表示已审核
- (IBAction)readPacketStateClickAction:(UIButton *)sender {
for (id object in self.view.subviews) {
if ([object isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)object;
button.selected = NO;
}
}
sender.selected = YES;
[self setupInstructionsViewOrigin:sender];
[self switchPaymentsVCAndWithdrawalVC:self.childViewControllers[sender.tag-100]];
}
@end