仿微博下拉提示

//初始化,将lab添加进入一个Img
UIImage *img = [[UIImage imageNamed:@"timeline_new_status_background.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:5]; _barView = [[UIImageView alloc] initWithImage:img]; _barView.frame = CGRectMake(5, -40, 320-10, 40); [self.view addSubview:_barView]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; label.tag = 100; label.font = [UIFont systemFontOfSize:16.0f]; label.textColor = [UIColor whiteColor]; label.backgroundColor = [UIColor clearColor]; [_barView addSubview:label]; [label release];

  

//显示出来2秒    
UILabel *label = (UILabel *)[_barView viewWithTag:100]; label.text = [NSString stringWithFormat:@"%d条微博更新",10]; [label sizeToFit]; CGRect frame = label.frame; frame.origin = CGPointMake((_barView.frame.size.width - frame.size.width)/2, (_barView.frame.size.height - frame.size.height)/2); label.frame = frame; [self performSelector:@selector(updateUI) withObject:nil afterDelay:2.0];

  

//慢慢消失   
[UIView animateWithDuration:0.6 animations:^{ CGRect frame = _barView.frame; frame.origin.y = 5; _barView.frame = frame; } completion:^(BOOL finished){ if (finished) { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelay:1.0]; [UIView setAnimationDuration:0.6]; CGRect frame = _barView.frame; frame.origin.y = -40; _barView.frame = frame; [UIView commitAnimations]; } }];

  

转载于:https://www.cnblogs.com/zcw-ios/articles/3328737.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值