自定義彈窗動(dòng)畫

- (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(@" 快關(guān)按鈕: %@",(sender.on ? @"ON" : @"OFF"));
    if (sender.on == YES) {
        NSLog(@"開");
        //spring動(dòng)畫
        [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(@"關(guān)");
        //spring動(dòng)畫
        [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) {
            
        }];
    }
}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末剑刑,一起剝皮案震驚了整個(gè)濱河市侮东,隨后出現(xiàn)的幾起案子计贰,更是在濱河造成了極大的恐慌,老刑警劉巖秀菱,帶你破解...
    沈念sama閱讀 219,539評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡分歇,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,594評(píng)論 3 396
  • 文/潘曉璐 我一進(jìn)店門笨使,熙熙樓的掌柜王于貴愁眉苦臉地迎上來卿樱,“玉大人,你說我怎么就攤上這事硫椰》钡鳎” “怎么了?”我有些...
    開封第一講書人閱讀 165,871評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵靶草,是天一觀的道長蹄胰。 經(jīng)常有香客問我,道長奕翔,這世上最難降的妖魔是什么裕寨? 我笑而不...
    開封第一講書人閱讀 58,963評(píng)論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮派继,結(jié)果婚禮上宾袜,老公的妹妹穿的比我還像新娘。我一直安慰自己驾窟,他們只是感情好庆猫,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,984評(píng)論 6 393
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著绅络,像睡著了一般月培。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上恩急,一...
    開封第一講書人閱讀 51,763評(píng)論 1 307
  • 那天杉畜,我揣著相機(jī)與錄音,去河邊找鬼衷恭。 笑死此叠,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的匾荆。 我是一名探鬼主播拌蜘,決...
    沈念sama閱讀 40,468評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼杆烁,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼!你這毒婦竟也來了简卧?” 一聲冷哼從身側(cè)響起兔魂,我...
    開封第一講書人閱讀 39,357評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎举娩,沒想到半個(gè)月后析校,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,850評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡铜涉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,002評(píng)論 3 338
  • 正文 我和宋清朗相戀三年智玻,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片芙代。...
    茶點(diǎn)故事閱讀 40,144評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡吊奢,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出纹烹,到底是詐尸還是另有隱情页滚,我是刑警寧澤,帶...
    沈念sama閱讀 35,823評(píng)論 5 346
  • 正文 年R本政府宣布铺呵,位于F島的核電站裹驰,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏片挂。R本人自食惡果不足惜幻林,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,483評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望音念。 院中可真熱鬧沪饺,春花似錦、人聲如沸闷愤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,026評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽肝谭。三九已至,卻和暖如春蛾扇,著一層夾襖步出監(jiān)牢的瞬間攘烛,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,150評(píng)論 1 272
  • 我被黑心中介騙來泰國打工镀首, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留坟漱,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,415評(píng)論 3 373
  • 正文 我出身青樓更哄,卻偏偏與公主長得像芋齿,于是被迫代替她去往敵國和親腥寇。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,092評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容