zoukankan      html  css  js  c++  java
  • IOS学习之路(二十五)UIView动画,弹出后移动然后消失

    首先在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;
        
    }
    

    效果图:






  • 相关阅读:
    放缩ImageView
    2017/5/3 afternoon
    2017/5/3 morning
    2017/5/2 afternoon
    2017/5/2 morning
    2017/4/28 afternoon
    2017/4/28 morning
    2017/4/27 afternoon
    2017/4/27 morning
    2017/4/26 afternoon
  • 原文地址:https://www.cnblogs.com/lixingle/p/3707720.html
Copyright © 2011-2022 走看看