您的位置:首页 > 产品设计 > UI/UE

IOS学习之路(二十五)UIView动画,弹出后移动然后消失

2013-10-27 19:43 239 查看
首先在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;

}


效果图:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐