Files

82 lines
2.5 KiB
Swift
Raw Permalink Normal View History

2015-12-30 18:47:13 -08:00
//
// XIONLogoView.swift
// XIONControlPanel
//
// Created by Charles Magahern on 12/30/15.
// Copyright © 2015 XION. All rights reserved.
//
import UIKit
2016-07-24 00:14:04 -07:00
class XIONLogoView: UIView
{
2017-05-13 00:40:03 -07:00
fileprivate var _xionLogoImageView: UIImageView = UIImageView()
fileprivate var _logoInnerRingImageView: UIImageView = UIImageView()
fileprivate var _logoOuterRingImageView: UIImageView = UIImageView()
2015-12-30 18:47:13 -08:00
override init(frame: CGRect)
{
super.init(frame: frame)
2017-05-13 00:40:03 -07:00
self.backgroundColor = UIColor.black
2015-12-30 18:47:13 -08:00
_xionLogoImageView.image = UIImage(named: "XIONLogoWithRing")
2017-05-13 00:40:03 -07:00
_xionLogoImageView.contentMode = .scaleAspectFit
2015-12-30 18:47:13 -08:00
_logoInnerRingImageView.image = UIImage(named: "XIONLogoInnerRing")
2017-05-13 00:40:03 -07:00
_logoInnerRingImageView.contentMode = .scaleAspectFit
2015-12-30 18:47:13 -08:00
_logoOuterRingImageView.image = UIImage(named: "XIONLogoOuterRing")
2017-05-13 00:40:03 -07:00
_logoOuterRingImageView.contentMode = .scaleAspectFit
2015-12-30 18:47:13 -08:00
self.addSubview(_logoOuterRingImageView)
self.addSubview(_logoInnerRingImageView)
self.addSubview(_xionLogoImageView)
}
required init?(coder aDecoder: NSCoder)
{
fatalError("unsupported")
}
override func layoutSubviews()
{
super.layoutSubviews()
let bounds = self.bounds
_xionLogoImageView.frame = bounds
_logoInnerRingImageView.frame = bounds
_logoOuterRingImageView.frame = bounds
}
// MARK: API
func beginAnimating()
{
self.stopAnimating()
2017-05-13 00:40:03 -07:00
let duration: TimeInterval = 20.0
2015-12-30 18:47:13 -08:00
let clockwiseAnim = CABasicAnimation(keyPath: "transform.rotation")
clockwiseAnim.fromValue = 0.0
clockwiseAnim.toValue = 2.0 * π
clockwiseAnim.duration = duration
clockwiseAnim.repeatCount = Float.infinity
let counterClockwiseAnim = CABasicAnimation(keyPath: "transform.rotation")
counterClockwiseAnim.fromValue = 2.0 * π
counterClockwiseAnim.toValue = 0.0
counterClockwiseAnim.duration = duration
counterClockwiseAnim.repeatCount = Float.infinity
2017-05-13 00:40:03 -07:00
_logoInnerRingImageView.layer.add(clockwiseAnim, forKey: "LogoClockwiseAnimation")
_logoOuterRingImageView.layer.add(counterClockwiseAnim, forKey: "LogoCounterclockwiseAnimation")
2015-12-30 18:47:13 -08:00
}
func stopAnimating()
{
_logoInnerRingImageView.layer.removeAllAnimations()
_logoOuterRingImageView.layer.removeAllAnimations()
}
}