sender.enabled = NO; CGFloat labW = 150; CGFloat labH = 30; CGFloat labX = (self.superview.frame.size.width -labW)*0.5; CGFloat labY = (self.superview.frame.size.height - labH) * 0.5; //新建一个label并且设置frame UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(labX, labY, labW, labH)]; //把label添加到你控件中 [self.superview addSubview:label]; //设置label文字 label.text = @"正在下载"; //设置label背影颜色 label.backgroundColor = [UIColor blackColor]; //设置文字居中 label.textAlignment = NSTextAlignmentCenter; //设置文字颜色 label.textColor = [UIColor redColor]; //设置背影色为透明 label.alpha = 0; //设置圆角 //1.设置切除半径 label.layer.cornerRadius = 5; //2.切除多余部分 label.layer.masksToBounds = YES; //执行block动画 [UIView animateWithDuration:1.5 animations:^{ label.alpha = 0.6; } completion:^(BOOL finished) { if (finished) { //UIViewAnimationOptionTransitionFlipFromLeft这仅仅是动画的一个效果 [UIView animateWithDuration:1.5 delay:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ label.alpha = 0.0; } completion:^(BOOL finished) { [label removeFromSuperview]; sender.enabled = YES; }]; } }];
时间: 2024-11-05 20:34:22