/**
* 显示最新微博熟练,给用户友善的提示
*/
- (void)showNewStatusCount:(int)count
{
//1.创建一个按钮,设置到导航栏的下面
UIButton *btn = [[UIButton alloc] init];
[self.navigationController.view insertSubview:btn belowSubview:self.navigationController.navigationBar];
//2.设置图片和文字
btn.userInteractionEnabled = NO;
[btn setBackgroundImage:[UIImage resizedImageWithName:@"timeline_new_status_background_os7"] forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:14];
[btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
if (count) {
[btn setTitle:[NSString stringWithFormat:@"共有%d条新微博",count] forState:UIControlStateNormal];
}else{
[btn setTitle:@"没有新的微博" forState:UIControlStateNormal];
}
//3.设置按钮的初始frame
CGFloat btnX = 0;
CGFloat btnH = 30;
CGFloat btnY = 64 - btnH;
CGFloat btnW = self.view.frame.size.width;
btn.frame = CGRectMake(btnX, btnY, btnW, btnH);
//4.动画移动按钮
[UIView animateWithDuration:0.7 animations:^{
btn.transform = CGAffineTransformMakeTranslation(0, btnH);
}completion:^(BOOL finished) {
//动画执行完毕后
[UIView animateKeyframesWithDuration:0.7 delay:1.0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
btn.transform = CGAffineTransformMakeTranslation(0, 0);
} completion:^(BOOL finished) {
[btn removeFromSuperview];
}];
}];
}
最新微博提示框
最新推荐文章于 2021-07-05 20:37:54 发布