zoukankan      html  css  js  c++  java
  • Swift

    Swift - RotateView

    效果

    源码

    https://github.com/YouXianMing/Swift-Animations

    //
    //  RotateView.swift
    //  Swift-Animations
    //
    //  Created by YouXianMing on 16/8/14.
    //  Copyright © 2016年 YouXianMing. All rights reserved.
    //
    
    import UIKit
    
    // MARK: Public class : RotateView
    
    class RotateView: UIView {
    
        // MARK: Properties.
        
        var rotateDuration : NSTimeInterval = 0.25
        
        // MARK: Animation method.
        
        func changeToUpAnimated(animated : Bool) {
            
            UIView.animateWithDuration((animated == true ? self.rotateDuration : 0.0)) {
                
                self.transform = self.defaultTransform
            }
        }
        
        func changeToLeftAnimated(animated : Bool) {
            
            UIView.animateWithDuration((animated == true ? self.rotateDuration : 0.0)) {
                
                self.transform = CGAffineTransformRotate(self.defaultTransform, CGFloat(-M_PI_2))
            }
        }
        
        func changeToRightAnimated(animated : Bool) {
            
            UIView.animateWithDuration((animated == true ? self.rotateDuration : 0.0)) {
                
                self.transform = CGAffineTransformRotate(self.defaultTransform, CGFloat(M_PI_2))
            }
        }
        
        func changeToDownAnimated(animated : Bool) {
            
            UIView.animateWithDuration((animated == true ? self.rotateDuration : 0.0)) {
                
                self.transform = CGAffineTransformRotate(self.defaultTransform, CGFloat(M_PI))
            }
        }
        
        // MARK: Private value & func & system method.
        
        private var defaultTransform : CGAffineTransform!
        
        override init(frame: CGRect) {
            
            super.init(frame : frame)
            defaultTransform = self.transform
        }
        
        required init?(coder aDecoder: NSCoder) {
            
            fatalError("init(coder:) has not been implemented")
        }
    }
  • 相关阅读:
    防止重复点击
    刷新当前页面的几种方法
    PHP删除数组中空值
    json转化数组
    两个不能同时共存的条件orWhere查询
    SQLSTATE[42000]
    laravel一个页面两个表格分页处理
    Hash::make与Hash::check
    unbind()清除指定元素绑定效果
    二级联动
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/5770992.html
Copyright © 2011-2022 走看看