IOS学习之路(二十五)UIView动画,弹出后移动然后消失
2013-10-27 19:43 Lves Li 阅读(581) 评论(0) 编辑 收藏 举报首先在viewdidload中添加UIlable并且把其设为隐藏
然后在点击按钮后,让其弹出移动后消失
//点击按钮后:
#pragma mark 点击关注按钮 - (IBAction)guanzhuBtnClick:(id)sender { self.myAlertLabel=[[UILabel alloc] initWithFrame:CGRectMake(275, 85, 15, 15)]; //起始高度设的大点 self.myAlertLabel.text=@"+"; self.myAlertLabel.backgroundColor=[UIColor clearColor]; //背景色设为透明 self.myAlertLabel.hidden=YES; [self.view addSubview:self.myAlertLabel]; if (self.myAlertLabel.hidden==YES) { self.myAlertLabel.textColor=[UIColor grayColor]; self.myAlertLabel.hidden=NO; [UIView animateWithDuration:0.5 //动画时间 delay:0.0 //开始延迟时间 options: UIViewAnimationCurveEaseInOut //弹入弹出 animations:^{ self.myAlertLabel.frame = CGRectMake(275, 75, 15, 15); //终止高度设的小于起始高度 } completion:^(BOOL finished){ if (finished) [self.myAlertLabel removeFromSuperview]; //移动后隐藏 }]; } // self.myAlertLabel.hidden=YES; }
效果图: