zoukankan      html  css  js  c++  java
  • MBProgressHud添加自定义动画

    在使用自定义view时,若直接使用,如下

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.label.text = @"加载中…";
    hud.mode = MBProgressHUDModeCustomView;
    UIImage *image = [[UIImage imageNamed:@"toast_loading"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    hud.customView = imgView;
    
    hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:1];
    //文字颜色
    hud.contentColor = [UIColor whiteColor];
    hud.animationType = MBProgressHUDAnimationFade;

    那么效果为

    若想使自定义view有动态效果,那么需要对UIImageView添加动画

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.label.text = @"加载中…";
    hud.mode = MBProgressHUDModeCustomView;
    UIImage *image = [[UIImage imageNamed:@"toast_loading"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    anima.toValue = @(M_PI*2);
    anima.duration = 1.0f;
    anima.repeatCount = 10;
    [imgView.layer addAnimation:anima forKey:nil];
    hud.customView = imgView;
    
    hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:1];
    //文字颜色
    hud.contentColor = [UIColor whiteColor];
    hud.animationType = MBProgressHUDAnimationFade;

    此时效果为

    最后补充,若想设置hud大小,可以用

    hud.minSize = CGSizeMake(165,90);
  • 相关阅读:
    分段和分页内存管理
    从文件/文件流的头字节中得到mime信息
    selenium中WebElement.getText()为空解决方法
    29个酷炫的Firefox配置参数
    web automation 常用技术比较
    误判心理学
    区块链+金融,带你直击实践应用中的需求和痛点
    供应链金融平台
    供应链金融的三种模式和四大趋势
    中国的支付清算体系是怎么玩的?
  • 原文地址:https://www.cnblogs.com/Apologize/p/5908555.html
Copyright © 2011-2022 走看看