zoukankan      html  css  js  c++  java
  • iOS 实现转盘的效果

    效果

    #import "ViewController.h"
    
    
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet UIImageView *panImageView;
    /**  */
    @property(nonatomic,assign)int angle;
    /** 转盘时间 */
    @property(strong,nonatomic)NSTimer *timer;
    /** 计时器 */
    @property(strong,nonatomic)NSTimer *timeTick;
    /** 计时时间 */
    @property(nonatomic,assign)int timeNumber;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.timeNumber = 3;
       self.timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startAnimation) userInfo:nil repeats:YES];
        self.timeTick = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
        
    }
    -(void)startAnimation
    {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1];
        [UIView setAnimationDelegate:self];
        _panImageView.animationRepeatCount = 1;
    //    [UIView setAnimationDidStopSelector:@selector(startAnimation)];
        self.angle += 1000;
        self.panImageView.layer.anchorPoint = CGPointMake(0.5,0.5);//以右下角为原点转,(0,0)是左上角转,(0.5,0,5)心中间转,其它以此类推
        self.panImageView.transform = CGAffineTransformMakeRotation(self.angle * (M_PI / 180.0f));
        
        [UIView commitAnimations];
        
    }
    
    -(void)timeFireMethod{
        self.timeNumber -- ;
        if (self.timeNumber == 0) {
            [self.timer invalidate];
        }
    
    
    }
    @end
  • 相关阅读:
    .NET Core使用swagger进行API接口文档管理
    此用户不允许自调用
    How to get raw request body in ASP.NET?
    支付宝app对接的坑
    PowerDesigner code、name显示设置 及 同时显示办法
    core里使用log4net
    core的微服务相关
    SQLPrompt 安装后sql上看不到菜单
    IIS配置支持跨域请求
    根据select出来的数据进行update
  • 原文地址:https://www.cnblogs.com/qianLL/p/5582737.html
Copyright © 2011-2022 走看看