//初始化,将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];
}
}];