label.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
label.textColor = [UIColor whiteColor];
label.font = [UIFont systemFontOfSize:14];
label.layer.cornerRadius = 10;
label.text = string;
label.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:label];
//设置动画
CATransition *transion = [CATransition animation];
transion.type = kCATransitionFade;
[label.layer addAnimation:transion forKey:nil];
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0*NSEC_PER_SEC));
dispatch_after(time, dispatch_get_main_queue(), ^{
[label removeFromSuperview];
});
网友评论