Added crawler
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Crawler.swift
|
||||
// ProgressKit
|
||||
//
|
||||
// Created by Kauntey Suryawanshi on 11/07/15.
|
||||
// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Cocoa
|
||||
|
||||
class Crawler: IndeterminateAnimation {
|
||||
|
||||
var backgroundLayer = CAShapeLayer()
|
||||
var starLayer = CAShapeLayer()
|
||||
var backgroundColor: NSColor = NSColor(calibratedWhite: 0, alpha: 0.39)
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
self.wantsLayer = true
|
||||
makeLayer()
|
||||
}
|
||||
|
||||
func makeLayer() {
|
||||
let rect = self.bounds
|
||||
let insetRect = NSInsetRect(rect, 20, 20)
|
||||
|
||||
self.layer?.borderColor = NSColor.blackColor().CGColor
|
||||
self.layer?.borderWidth = 1
|
||||
|
||||
/// Add background layer
|
||||
do_ {
|
||||
backgroundLayer.bounds = insetRect
|
||||
backgroundLayer.borderWidth = 3
|
||||
backgroundLayer.position = insetRect.mid
|
||||
backgroundLayer.borderColor = NSColor.blackColor().CGColor
|
||||
backgroundLayer.backgroundColor = NSColor.grayColor().CGColor
|
||||
backgroundLayer.cornerRadius = NSWidth(insetRect) / 2
|
||||
self.layer?.addSublayer(backgroundLayer)
|
||||
}
|
||||
|
||||
do_ {
|
||||
starLayer.backgroundColor = NSColor.lightGrayColor().CGColor
|
||||
starLayer.bounds = CGRect(x: 0, y: 0, width: 20, height: 20)
|
||||
starLayer.cornerRadius = 10
|
||||
starLayer.position = CGPoint(x: rect.midX, y: rect.midY + insetRect.height / 2)
|
||||
self.layer?.addSublayer(starLayer)
|
||||
|
||||
var arcPath = NSBezierPath()
|
||||
arcPath.appendBezierPathWithArcWithCenter(insetRect.mid, radius: insetRect.width / 2, startAngle: 90, endAngle: -360 + 90, clockwise: true)
|
||||
|
||||
var rotationAnimation = CAKeyframeAnimation(keyPath: "position")
|
||||
rotationAnimation.path = arcPath.CGPath
|
||||
rotationAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
|
||||
rotationAnimation.removedOnCompletion = false
|
||||
rotationAnimation.duration = 2
|
||||
rotationAnimation.repeatCount = Float.infinity
|
||||
starLayer.addAnimation(rotationAnimation, forKey: "rotate")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,12 +125,9 @@ class CircularSnail: IndeterminateAnimation {
|
||||
}
|
||||
|
||||
override func startAnimation() {
|
||||
progressLayer.addAnimation(animationGroup, forKey: "strokeEnd")
|
||||
backgroundLayer.addAnimation(rotationAnimation, forKey: rotationAnimation.keyPath)
|
||||
}
|
||||
|
||||
override func stopAnimation() {
|
||||
backgroundLayer.removeAllAnimations()
|
||||
progressLayer.removeAllAnimations()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
E36CDEE71B5178830095E43F /* Crawler.swift in Sources */ = {isa = PBXBuildFile; fileRef = E36CDEE61B5178830095E43F /* Crawler.swift */; };
|
||||
E3918F811B4E88CF00558DAB /* CircularProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3918F801B4E88CF00558DAB /* CircularProgressView.swift */; };
|
||||
E3918F841B4E88DE00558DAB /* CircularSnail.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3918F821B4E88DE00558DAB /* CircularSnail.swift */; };
|
||||
E3918F851B4E88DE00558DAB /* ShootingStars.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3918F831B4E88DE00558DAB /* ShootingStars.swift */; };
|
||||
@@ -32,6 +33,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
E36CDEE61B5178830095E43F /* Crawler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Crawler.swift; sourceTree = "<group>"; };
|
||||
E3918F801B4E88CF00558DAB /* CircularProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CircularProgressView.swift; path = Determinate/CircularProgressView.swift; sourceTree = "<group>"; };
|
||||
E3918F821B4E88DE00558DAB /* CircularSnail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CircularSnail.swift; path = InDeterminate/CircularSnail.swift; sourceTree = "<group>"; };
|
||||
E3918F831B4E88DE00558DAB /* ShootingStars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ShootingStars.swift; path = InDeterminate/ShootingStars.swift; sourceTree = "<group>"; };
|
||||
@@ -74,6 +76,7 @@
|
||||
E3918F8C1B4E8AB100558DAB /* IndeterminateAnimation.swift */,
|
||||
E3918F821B4E88DE00558DAB /* CircularSnail.swift */,
|
||||
E3918FA71B4ECF7100558DAB /* Rainbow.swift */,
|
||||
E36CDEE61B5178830095E43F /* Crawler.swift */,
|
||||
E3918F831B4E88DE00558DAB /* ShootingStars.swift */,
|
||||
);
|
||||
name = Indeterminate;
|
||||
@@ -253,6 +256,7 @@
|
||||
E3918F841B4E88DE00558DAB /* CircularSnail.swift in Sources */,
|
||||
E3AD65D81B426758009541CD /* AppDelegate.swift in Sources */,
|
||||
E3918FA81B4ECF7100558DAB /* Rainbow.swift in Sources */,
|
||||
E36CDEE71B5178830095E43F /* Crawler.swift in Sources */,
|
||||
E3918F8F1B4E8C2900558DAB /* DeterminateAnimation.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -666,7 +666,7 @@
|
||||
<!--Tab View Controller-->
|
||||
<scene sceneID="rXQ-85-vI9">
|
||||
<objects>
|
||||
<tabViewController selectedTabViewItemIndex="0" id="GTh-XG-eDn" sceneMemberID="viewController">
|
||||
<tabViewController selectedTabViewItemIndex="1" id="GTh-XG-eDn" sceneMemberID="viewController">
|
||||
<tabViewItems>
|
||||
<tabViewItem label="Determinate" id="90h-OW-Y1a"/>
|
||||
<tabViewItem label="Indeterminate" id="T4v-4q-PhE"/>
|
||||
@@ -896,6 +896,9 @@ Dark colors</string>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</box>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JiO-EY-sex" customClass="Crawler" customModule="ProgressKit" customModuleProvider="target">
|
||||
<rect key="frame" x="315" y="202" width="132" height="132"/>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
<connections>
|
||||
|
||||
Reference in New Issue
Block a user