- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"我的订单";
self.view.backgroundColor = [UIColor whiteColor];
_dataSourch = [NSMutableArray array];
[_dataSourch addObjectsFromArray:@[@"",@"",@"",@"",@"",@"",@"",@""]];
[self.view addSubview:self.TableView];
// [self.navigationController popViewControllerAnimated:YES];
[self createNav];
//初始化弹窗view;
PopUps = [[UIView alloc]init];
PopUps.frame = CGRectMake(WIDTH / 2 - ((WIDTH - 20)/2),HEIGHT-15,WIDTH - 20,10);
PopUps.layer.backgroundColor = [UIColor colorWithRed:52/255.0 green:132/255.0 blue:255/255.0 alpha:0.3].CGColor;
PopUps.layer.cornerRadius = 6;
[self.view addSubview:PopUps];
//已选择课程lable
statistics = [[UILabel alloc]initWithFrame:CGRectMake(42, 10, 200, 20)];
statistics.numberOfLines = 0;
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"一共挑选了( 1 )套小课程"attributes: @{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 14],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
statistics.attributedText = string;
statistics.textAlignment = NSTextAlignmentLeft;
statistics .alpha = 0;
[PopUps addSubview:statistics];
//总金额lable
totalAmount = [[UILabel alloc] init];
totalAmount.frame = CGRectMake(42,35,128,25);
totalAmount.numberOfLines = 0;
NSMutableAttributedString *string1 = [[NSMutableAttributedString alloc] initWithString:@"总金额:29.9元"attributes: @{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Semibold" size: 18],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
totalAmount.attributedText = string1;
totalAmount.textAlignment = NSTextAlignmentLeft;
totalAmount.alpha = 0;
[PopUps addSubview:totalAmount];
//全选按钮
checkAllBtn = [LOTAnimatedSwitch switchNamed:@"animation-w320-h320 (1)"];
[checkAllBtn addTarget:self action:@selector(checkAllBtnBTN:) forControlEvents:UIControlEventTouchUpInside];
// checkAllBtn.backgroundColor = [UIColor redColor];
// UIImageView * checkAllBtnimgv = [[UIImageView alloc]initWithFrame:CGRectMake(10, 30, 20, 20)];
// checkAllBtnimgv.image = [UIImage imageNamed:@"未选中样式"];
[checkAllBtn setProgressRangeForOnState:0 toProgress:1];
[checkAllBtn setProgressRangeForOffState:1 toProgress:0];
checkAllBtn.frame = CGRectMake(-15, -2, 80, 80);
checkAllBtn.alpha = 0;
[PopUps addSubview:checkAllBtn];
purchaseButton = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH - 20 - 116 - 15, 20 , 116, 35)];
[purchaseButton setTitle:@"马上支付" forState:UIControlStateNormal];
purchaseButton.layer.masksToBounds = YES;
purchaseButton.layer.cornerRadius = 10;
purchaseButton.backgroundColor = RGBA_COLOR(255, 169, 63, 1);
purchaseButton.alpha = 0;
[PopUps addSubview:purchaseButton];
}
-(void)BTN:(LOTAnimatedSwitch *)sender {
NSLog(@" 快关按钮: %@",(sender.on ? @"ON" : @"OFF"));
if (sender.on == YES) {
NSLog(@"开");
//spring动画
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->PopUps.layer.frame = CGRectMake(10,HEIGHT - 75 - 20,WIDTH - 20,75);
self->PopUps.layer.cornerRadius = 30;
self->PopUps.layer.shadowColor = RGBA_COLOR(52, 132, 255, 0.85).CGColor;
self->PopUps.layer.shadowOffset = CGSizeMake(0,10);
self->PopUps.layer.shadowOpacity = 10;
self->PopUps.layer.shadowRadius = 20;
self->PopUps.layer.backgroundColor = [UIColor colorWithRed:52/255.0 green:132/255.0 blue:255/255.0 alpha:0.8].CGColor;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0.3 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->statistics.alpha = 1;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0.3 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->totalAmount.alpha = 1;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0.45 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->purchaseButton.alpha = 1;
// self->purchaseButton.layer.frame = CGRectMake(224, 20 , 116, 35);
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0.45 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->checkAllBtn.alpha = 1;
} completion:^(BOOL finished) {
}];
}else{
NSLog(@"关");
//spring动画
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.7 initialSpringVelocity:0.8 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self->PopUps.layer.frame = CGRectMake(WIDTH / 2 - ((WIDTH - 20)/2),HEIGHT-15,WIDTH - 20,10);
self->PopUps.layer.cornerRadius = 6;
self->PopUps.layer.backgroundColor = [UIColor colorWithRed:52/255.0 green:132/255.0 blue:255/255.0 alpha:0.3].CGColor;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->statistics.alpha = 0;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->totalAmount.alpha = 0;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->purchaseButton.alpha = 0;
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0.6 options:UIViewAnimationOptionOverrideInheritedCurve animations:^{
self->checkAllBtn.alpha = 0;
} completion:^(BOOL finished) {
}];
}
}