Commit af8066c7 by Daniel Dahan

updated pulse animation

parent f7d9b1c8
...@@ -276,7 +276,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg ...@@ -276,7 +276,6 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
captureButton.width = 72 captureButton.width = 72
captureButton.height = 72 captureButton.height = 72
captureButton.pulseColor = MaterialColor.white captureButton.pulseColor = MaterialColor.white
captureButton.pulseFill = true
captureButton.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3) captureButton.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
captureButton.borderWidth = .Border2 captureButton.borderWidth = .Border2
captureButton.borderColor = MaterialColor.white captureButton.borderColor = MaterialColor.white
......
...@@ -76,7 +76,6 @@ class ViewController: UIViewController { ...@@ -76,7 +76,6 @@ class ViewController: UIViewController {
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blue.lighten1 btn1.pulseColor = MaterialColor.blue.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setTitle("YES", forState: .Normal) btn1.setTitle("YES", forState: .Normal)
btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal) btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
...@@ -84,7 +83,6 @@ class ViewController: UIViewController { ...@@ -84,7 +83,6 @@ class ViewController: UIViewController {
// No button. // No button.
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.blue.lighten1 btn2.pulseColor = MaterialColor.blue.lighten1
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setTitle("NO", forState: .Normal) btn2.setTitle("NO", forState: .Normal)
btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal) btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
...@@ -132,7 +130,6 @@ class ViewController: UIViewController { ...@@ -132,7 +130,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_favorite_white") let img1: UIImage? = UIImage(named: "ic_favorite_white")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -177,7 +174,6 @@ class ViewController: UIViewController { ...@@ -177,7 +174,6 @@ class ViewController: UIViewController {
// LEARN MORE button. // LEARN MORE button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.teal.lighten1 btn1.pulseColor = MaterialColor.teal.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setTitle("LEARN MORE", forState: .Normal) btn1.setTitle("LEARN MORE", forState: .Normal)
btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal) btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal)
...@@ -207,7 +203,6 @@ class ViewController: UIViewController { ...@@ -207,7 +203,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_search_white") let img1: UIImage? = UIImage(named: "ic_search_white")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -215,7 +210,6 @@ class ViewController: UIViewController { ...@@ -215,7 +210,6 @@ class ViewController: UIViewController {
// BUTTON 1 button. // BUTTON 1 button.
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.teal.lighten3 btn2.pulseColor = MaterialColor.teal.lighten3
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setTitle("BUTTON 1", forState: .Normal) btn2.setTitle("BUTTON 1", forState: .Normal)
btn2.setTitleColor(MaterialColor.teal.lighten3, forState: .Normal) btn2.setTitleColor(MaterialColor.teal.lighten3, forState: .Normal)
...@@ -224,7 +218,6 @@ class ViewController: UIViewController { ...@@ -224,7 +218,6 @@ class ViewController: UIViewController {
// BUTTON 2 button. // BUTTON 2 button.
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.teal.lighten3 btn3.pulseColor = MaterialColor.teal.lighten3
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setTitle("BUTTON 2", forState: .Normal) btn3.setTitle("BUTTON 2", forState: .Normal)
btn3.setTitleColor(MaterialColor.teal.lighten3, forState: .Normal) btn3.setTitleColor(MaterialColor.teal.lighten3, forState: .Normal)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
967513F01C13EB69009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513EF1C13EB69009F455A /* ViewController.swift */; }; 967513F01C13EB69009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513EF1C13EB69009F455A /* ViewController.swift */; };
967513F51C13EB69009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513F41C13EB69009F455A /* Assets.xcassets */; }; 967513F51C13EB69009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513F41C13EB69009F455A /* Assets.xcassets */; };
967513F81C13EB69009F455A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 967513F61C13EB69009F455A /* LaunchScreen.storyboard */; }; 967513F81C13EB69009F455A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 967513F61C13EB69009F455A /* LaunchScreen.storyboard */; };
96FE30331C63ADE900548232 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30321C63ADE900548232 /* Material.framework */; };
96FE30341C63ADE900548232 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30321C63ADE900548232 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96FE30341C63ADE900548232 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
967513F41C13EB69009F455A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 967513F41C13EB69009F455A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
967513F71C13EB69009F455A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 967513F71C13EB69009F455A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
967513F91C13EB69009F455A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 967513F91C13EB69009F455A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96FE30321C63ADE900548232 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96FE30331C63ADE900548232 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
967513E11C13EB69009F455A = { 967513E11C13EB69009F455A = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96FE30321C63ADE900548232 /* Material.framework */,
967513EC1C13EB69009F455A /* ImageCardView */, 967513EC1C13EB69009F455A /* ImageCardView */,
967513EB1C13EB69009F455A /* Products */, 967513EB1C13EB69009F455A /* Products */,
); );
......
...@@ -79,7 +79,6 @@ class ViewController: UIViewController { ...@@ -79,7 +79,6 @@ class ViewController: UIViewController {
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.cyan.lighten1 btn1.pulseColor = MaterialColor.cyan.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setTitle("YES", forState: .Normal) btn1.setTitle("YES", forState: .Normal)
btn1.setTitleColor(MaterialColor.cyan.darken1, forState: .Normal) btn1.setTitleColor(MaterialColor.cyan.darken1, forState: .Normal)
...@@ -87,7 +86,6 @@ class ViewController: UIViewController { ...@@ -87,7 +86,6 @@ class ViewController: UIViewController {
// No button. // No button.
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.cyan.lighten1 btn2.pulseColor = MaterialColor.cyan.lighten1
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setTitle("NO", forState: .Normal) btn2.setTitle("NO", forState: .Normal)
btn2.setTitleColor(MaterialColor.cyan.darken1, forState: .Normal) btn2.setTitleColor(MaterialColor.cyan.darken1, forState: .Normal)
...@@ -124,7 +122,6 @@ class ViewController: UIViewController { ...@@ -124,7 +122,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2") let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blueGrey.lighten1 btn1.pulseColor = MaterialColor.blueGrey.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -133,7 +130,6 @@ class ViewController: UIViewController { ...@@ -133,7 +130,6 @@ class ViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_favorite_grey_darken_2") let img2: UIImage? = UIImage(named: "ic_favorite_grey_darken_2")
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.blueGrey.lighten1 btn2.pulseColor = MaterialColor.blueGrey.lighten1
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted) btn2.setImage(img2, forState: .Highlighted)
...@@ -142,7 +138,6 @@ class ViewController: UIViewController { ...@@ -142,7 +138,6 @@ class ViewController: UIViewController {
let img3: UIImage? = UIImage(named: "ic_share_grey_darken_2") let img3: UIImage? = UIImage(named: "ic_share_grey_darken_2")
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.blueGrey.lighten1 btn3.pulseColor = MaterialColor.blueGrey.lighten1
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
965E8E741C14A4950035A270 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E731C14A4950035A270 /* ViewController.swift */; }; 965E8E741C14A4950035A270 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E731C14A4950035A270 /* ViewController.swift */; };
965E8E791C14A4950035A270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E781C14A4950035A270 /* Assets.xcassets */; }; 965E8E791C14A4950035A270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E781C14A4950035A270 /* Assets.xcassets */; };
965E8E7C1C14A4950035A270 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E7A1C14A4950035A270 /* LaunchScreen.storyboard */; }; 965E8E7C1C14A4950035A270 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E7A1C14A4950035A270 /* LaunchScreen.storyboard */; };
96FE30391C63B00200548232 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30381C63B00200548232 /* Material.framework */; };
96FE303A1C63B00200548232 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30381C63B00200548232 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96FE303A1C63B00200548232 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
965E8E781C14A4950035A270 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 965E8E781C14A4950035A270 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
965E8E7B1C14A4950035A270 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 965E8E7B1C14A4950035A270 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
965E8E7D1C14A4950035A270 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 965E8E7D1C14A4950035A270 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96FE30381C63B00200548232 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96FE30391C63B00200548232 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
965E8E651C14A4950035A270 = { 965E8E651C14A4950035A270 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96FE30381C63B00200548232 /* Material.framework */,
965E8E701C14A4950035A270 /* MaterialButton */, 965E8E701C14A4950035A270 /* MaterialButton */,
965E8E6F1C14A4950035A270 /* Products */, 965E8E6F1C14A4950035A270 /* Products */,
); );
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
96DB1C611C14AA2800825BE6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DB1C601C14AA2800825BE6 /* ViewController.swift */; }; 96DB1C611C14AA2800825BE6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DB1C601C14AA2800825BE6 /* ViewController.swift */; };
96DB1C661C14AA2800825BE6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96DB1C651C14AA2800825BE6 /* Assets.xcassets */; }; 96DB1C661C14AA2800825BE6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96DB1C651C14AA2800825BE6 /* Assets.xcassets */; };
96DB1C691C14AA2800825BE6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96DB1C671C14AA2800825BE6 /* LaunchScreen.storyboard */; }; 96DB1C691C14AA2800825BE6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96DB1C671C14AA2800825BE6 /* LaunchScreen.storyboard */; };
96FE30361C63AFAD00548232 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30351C63AFAD00548232 /* Material.framework */; };
96FE30371C63AFAD00548232 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96FE30351C63AFAD00548232 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96FE30371C63AFAD00548232 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
96DB1C651C14AA2800825BE6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96DB1C651C14AA2800825BE6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96DB1C681C14AA2800825BE6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96DB1C681C14AA2800825BE6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96DB1C6A1C14AA2800825BE6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96DB1C6A1C14AA2800825BE6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96FE30351C63AFAD00548232 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96FE30361C63AFAD00548232 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
96DB1C521C14AA2800825BE6 = { 96DB1C521C14AA2800825BE6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96FE30351C63AFAD00548232 /* Material.framework */,
96DB1C5D1C14AA2800825BE6 /* MaterialPulseView */, 96DB1C5D1C14AA2800825BE6 /* MaterialPulseView */,
96DB1C5C1C14AA2800825BE6 /* Products */, 96DB1C5C1C14AA2800825BE6 /* Products */,
); );
......
...@@ -75,13 +75,13 @@ class ViewController: UIViewController { ...@@ -75,13 +75,13 @@ class ViewController: UIViewController {
pulseView.animate(MaterialAnimation.rotate(3, duration: 3)) pulseView.animate(MaterialAnimation.rotate(3, duration: 3))
UIView.animateWithDuration(0.4, UIView.animateWithDuration(0.5,
delay: 3, delay: 3,
usingSpringWithDamping: 0.6, usingSpringWithDamping: 0.6,
initialSpringVelocity: 0, initialSpringVelocity: 0,
options: .AllowUserInteraction, options: .AllowUserInteraction,
animations: { animations: {
pulseView.frame.origin.x = 300 pulseView.y = 300
}, completion: nil) }, completion: nil)
} }
} }
......
...@@ -74,13 +74,13 @@ class ViewController: UIViewController { ...@@ -74,13 +74,13 @@ class ViewController: UIViewController {
// Add materialView to UIViewController. // Add materialView to UIViewController.
view.addSubview(materialView) view.addSubview(materialView)
UIView.animateWithDuration(0.4, UIView.animateWithDuration(0.5,
delay: 3, delay: 3,
usingSpringWithDamping: 0.6, usingSpringWithDamping: 0.6,
initialSpringVelocity: 0, initialSpringVelocity: 0,
options: .AllowUserInteraction, options: .AllowUserInteraction,
animations: { animations: {
materialView.frame.origin.x = 300 materialView.y = 300
}, completion: nil) }, completion: nil)
} }
} }
......
...@@ -202,7 +202,6 @@ class ViewController: UIViewController { ...@@ -202,7 +202,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -211,7 +210,6 @@ class ViewController: UIViewController { ...@@ -211,7 +210,6 @@ class ViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_star_white") let img2: UIImage? = UIImage(named: "ic_star_white")
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white btn2.pulseColor = MaterialColor.white
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted) btn2.setImage(img2, forState: .Highlighted)
...@@ -220,7 +218,6 @@ class ViewController: UIViewController { ...@@ -220,7 +218,6 @@ class ViewController: UIViewController {
let img3: UIImage? = UIImage(named: "ic_search_white") let img3: UIImage? = UIImage(named: "ic_search_white")
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.white btn3.pulseColor = MaterialColor.white
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
...@@ -273,7 +270,6 @@ class ViewController: UIViewController { ...@@ -273,7 +270,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -282,7 +278,6 @@ class ViewController: UIViewController { ...@@ -282,7 +278,6 @@ class ViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_star_white") let img2: UIImage? = UIImage(named: "ic_star_white")
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white btn2.pulseColor = MaterialColor.white
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted) btn2.setImage(img2, forState: .Highlighted)
...@@ -291,7 +286,6 @@ class ViewController: UIViewController { ...@@ -291,7 +286,6 @@ class ViewController: UIViewController {
let img3: UIImage? = UIImage(named: "ic_search_white") let img3: UIImage? = UIImage(named: "ic_search_white")
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.white btn3.pulseColor = MaterialColor.white
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
......
...@@ -143,7 +143,6 @@ class MainViewController: UIViewController { ...@@ -143,7 +143,6 @@ class MainViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_menu_white")?.imageWithRenderingMode(.AlwaysTemplate) let img1: UIImage? = UIImage(named: "ic_menu_white")?.imageWithRenderingMode(.AlwaysTemplate)
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = MaterialColor.white
menuButton.pulseFill = true
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.setImage(img1, forState: .Normal) menuButton.setImage(img1, forState: .Normal)
menuButton.setImage(img1, forState: .Highlighted) menuButton.setImage(img1, forState: .Highlighted)
...@@ -157,7 +156,6 @@ class MainViewController: UIViewController { ...@@ -157,7 +156,6 @@ class MainViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate) let img2: UIImage? = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = MaterialColor.white
searchButton.pulseFill = true
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.setImage(img2, forState: .Normal) searchButton.setImage(img2, forState: .Normal)
searchButton.setImage(img2, forState: .Highlighted) searchButton.setImage(img2, forState: .Highlighted)
......
...@@ -73,7 +73,6 @@ class ViewController: UIViewController { ...@@ -73,7 +73,6 @@ class ViewController: UIViewController {
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blue.lighten1 btn1.pulseColor = MaterialColor.blue.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setTitle("YES", forState: .Normal) btn1.setTitle("YES", forState: .Normal)
btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal) btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
...@@ -81,7 +80,6 @@ class ViewController: UIViewController { ...@@ -81,7 +80,6 @@ class ViewController: UIViewController {
// No button. // No button.
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.blue.lighten1 btn2.pulseColor = MaterialColor.blue.lighten1
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setTitle("NO", forState: .Normal) btn2.setTitle("NO", forState: .Normal)
btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal) btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
...@@ -119,7 +117,6 @@ class ViewController: UIViewController { ...@@ -119,7 +117,6 @@ class ViewController: UIViewController {
// LEARN MORE button. // LEARN MORE button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.teal.lighten1 btn1.pulseColor = MaterialColor.teal.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setTitle("LEARN MORE", forState: .Normal) btn1.setTitle("LEARN MORE", forState: .Normal)
btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal) btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal)
......
...@@ -64,7 +64,6 @@ class ViewController: UIViewController { ...@@ -64,7 +64,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2") let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blueGrey.lighten1 btn1.pulseColor = MaterialColor.blueGrey.lighten1
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -73,7 +72,6 @@ class ViewController: UIViewController { ...@@ -73,7 +72,6 @@ class ViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_favorite_grey_darken_2") let img2: UIImage? = UIImage(named: "ic_favorite_grey_darken_2")
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.blueGrey.lighten1 btn2.pulseColor = MaterialColor.blueGrey.lighten1
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted) btn2.setImage(img2, forState: .Highlighted)
...@@ -82,7 +80,6 @@ class ViewController: UIViewController { ...@@ -82,7 +80,6 @@ class ViewController: UIViewController {
let img3: UIImage? = UIImage(named: "ic_share_grey_darken_2") let img3: UIImage? = UIImage(named: "ic_share_grey_darken_2")
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.blueGrey.lighten1 btn3.pulseColor = MaterialColor.blueGrey.lighten1
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
......
...@@ -85,7 +85,6 @@ class ViewController: UIViewController { ...@@ -85,7 +85,6 @@ class ViewController: UIViewController {
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
...@@ -94,7 +93,6 @@ class ViewController: UIViewController { ...@@ -94,7 +93,6 @@ class ViewController: UIViewController {
let img2: UIImage? = UIImage(named: "ic_star_white") let img2: UIImage? = UIImage(named: "ic_star_white")
let btn2: FlatButton = FlatButton() let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white btn2.pulseColor = MaterialColor.white
btn2.pulseFill = true
btn2.pulseScale = false btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted) btn2.setImage(img2, forState: .Highlighted)
...@@ -103,7 +101,6 @@ class ViewController: UIViewController { ...@@ -103,7 +101,6 @@ class ViewController: UIViewController {
let img3: UIImage? = UIImage(named: "ic_search_white") let img3: UIImage? = UIImage(named: "ic_search_white")
let btn3: FlatButton = FlatButton() let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.white btn3.pulseColor = MaterialColor.white
btn3.pulseFill = true
btn3.pulseScale = false btn3.pulseScale = false
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
......
...@@ -40,9 +40,6 @@ public class MaterialButton : UIButton { ...@@ -40,9 +40,6 @@ public class MaterialButton : UIButton {
*/ */
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
/// A CAShapeLayer used in the pulse animation.
public private(set) lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/** /**
A base delegate reference used when subclassing MaterialView. A base delegate reference used when subclassing MaterialView.
*/ */
...@@ -51,40 +48,11 @@ public class MaterialButton : UIButton { ...@@ -51,40 +48,11 @@ public class MaterialButton : UIButton {
/// Sets whether the scaling animation should be used. /// Sets whether the scaling animation should be used.
public lazy var pulseScale: Bool = true public lazy var pulseScale: Bool = true
/// Enables and disables the spotlight effect.
public var spotlight: Bool = false {
didSet {
if spotlight {
pulseFill = false
}
}
}
/**
Determines if the pulse animation should fill the entire
view.
*/
public var pulseFill: Bool = false {
didSet {
if pulseFill {
spotlight = false
}
}
}
/// The opcaity value for the pulse animation. /// The opcaity value for the pulse animation.
public var pulseColorOpacity: CGFloat = 0.25 { public var pulseColorOpacity: CGFloat = 0.25
didSet {
updatePulseLayer()
}
}
/// The color of the pulse effect. /// The color of the pulse effect.
public var pulseColor: UIColor? { public var pulseColor: UIColor?
didSet {
updatePulseLayer()
}
}
/** /**
This property is the same as clipsToBounds. It crops any of the view's This property is the same as clipsToBounds. It crops any of the view's
...@@ -398,47 +366,7 @@ public class MaterialButton : UIButton { ...@@ -398,47 +366,7 @@ public class MaterialButton : UIButton {
*/ */
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event) super.touchesBegan(touches, withEvent: event)
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer) pulse(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
let v: CGFloat = r / f
let d: CGFloat = 2 * f
let s: CGFloat = 1.05
let t: CFTimeInterval = 0.25
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animationDisabled { [unowned self] in
self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point
self.pulseLayer.cornerRadius = r / d
self.pulseLayer.hidden = false
}
pulseLayer.addAnimation(MaterialAnimation.scale(pulseFill ? 3 * d : 1.5 * d, duration: t), forKey: nil)
}
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
}
}
/**
A delegation method that is executed when the view touch event is
moving.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesMoved(touches, withEvent: event)
if spotlight {
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if layer.containsPoint(point) {
MaterialAnimation.animationDisabled { [unowned self] in
self.pulseLayer.position = point
}
}
}
} }
/** /**
...@@ -463,6 +391,54 @@ public class MaterialButton : UIButton { ...@@ -463,6 +391,54 @@ public class MaterialButton : UIButton {
shrinkAnimation() shrinkAnimation()
} }
/// Triggers the pulse animation.
public func pulse(point: CGPoint) {
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
let v: CGFloat = r / f
let d: CGFloat = 2 * f
let s: CGFloat = 1.05
var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t {
t = 0.55
} else if 0.25 > t {
t = 0.55
}
t /= 1.3
if nil != pulseColor && 0 < pulseColorOpacity {
let pulseLayer: CAShapeLayer = CAShapeLayer()
pulseLayer.hidden = true
pulseLayer.zPosition = 1
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
visualLayer.addSublayer(pulseLayer)
MaterialAnimation.animationDisabled {
pulseLayer.bounds = CGRectMake(0, 0, v, v)
pulseLayer.position = point
pulseLayer.cornerRadius = r / d
pulseLayer.hidden = false
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [unowned self] in
if nil != self.pulseColor && 0 < self.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
pulseLayer.removeFromSuperlayer()
}
}
}
}
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
}
}
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method it is recommended to override the prepareView method
...@@ -472,7 +448,6 @@ public class MaterialButton : UIButton { ...@@ -472,7 +448,6 @@ public class MaterialButton : UIButton {
*/ */
public func prepareView() { public func prepareView() {
prepareVisualLayer() prepareVisualLayer()
preparePulseLayer()
shadowColor = MaterialColor.black shadowColor = MaterialColor.black
borderColor = MaterialColor.black borderColor = MaterialColor.black
pulseColor = MaterialColor.white pulseColor = MaterialColor.white
...@@ -500,32 +475,17 @@ public class MaterialButton : UIButton { ...@@ -500,32 +475,17 @@ public class MaterialButton : UIButton {
} }
} }
/// Prepares the pulseLayer property.
internal func preparePulseLayer() {
pulseLayer.hidden = true
pulseLayer.zPosition = 1
visualLayer.addSublayer(pulseLayer)
}
/// Updates the pulseLayer when settings have changed.
internal func updatePulseLayer() {
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
}
/// Executes the shrink animation for the pulse effect. /// Executes the shrink animation for the pulse effect.
internal func shrinkAnimation() { internal func shrinkAnimation() {
let t: CFTimeInterval = 0.25
let s: CGFloat = 1
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: { [unowned self] in
self.pulseLayer.hidden = true
})
pulseLayer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
if pulseScale { if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil) var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t {
t = 0.55
} else if 0.25 > t {
t = 0.55
}
t /= 1.3
layer.addAnimation(MaterialAnimation.scale(1, duration: t), forKey: nil)
} }
} }
} }
\ No newline at end of file
...@@ -31,46 +31,14 @@ ...@@ -31,46 +31,14 @@
import UIKit import UIKit
public class MaterialPulseView : MaterialView { public class MaterialPulseView : MaterialView {
/// A CAShapeLayer used in the pulse animation.
public private(set) lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/// Sets whether the scaling animation should be used. /// Sets whether the scaling animation should be used.
public lazy var pulseScale: Bool = true public lazy var pulseScale: Bool = true
/// Enables and disables the spotlight effect.
public var spotlight: Bool = false {
didSet {
if spotlight {
pulseFill = false
}
}
}
/**
Determines if the pulse animation should fill the entire
view.
*/
public var pulseFill: Bool = false {
didSet {
if pulseFill {
spotlight = false
}
}
}
/// The opcaity value for the pulse animation. /// The opcaity value for the pulse animation.
public var pulseColorOpacity: CGFloat = 0.25 { public var pulseColorOpacity: CGFloat = 0.25
didSet {
updatePulseLayer()
}
}
/// The color of the pulse effect. /// The color of the pulse effect.
public var pulseColor: UIColor? { public var pulseColor: UIColor?
didSet {
updatePulseLayer()
}
}
/** /**
A delegation method that is executed when the view has began a A delegation method that is executed when the view has began a
...@@ -80,47 +48,7 @@ public class MaterialPulseView : MaterialView { ...@@ -80,47 +48,7 @@ public class MaterialPulseView : MaterialView {
*/ */
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event) super.touchesBegan(touches, withEvent: event)
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer) pulse(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
let v: CGFloat = r / f
let d: CGFloat = 2 * f
let s: CGFloat = 1.05
let t: CFTimeInterval = 0.25
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animationDisabled { [unowned self] in
self.pulseLayer.bounds = CGRectMake(0, 0, v, v)
self.pulseLayer.position = point
self.pulseLayer.cornerRadius = r / d
self.pulseLayer.hidden = false
}
pulseLayer.addAnimation(MaterialAnimation.scale(pulseFill ? 3 * d : d, duration: t), forKey: nil)
}
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
}
}
/**
A delegation method that is executed when the view touch event is
moving.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesMoved(touches, withEvent: event)
if spotlight {
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if layer.containsPoint(point) {
MaterialAnimation.animationDisabled { [unowned self] in
self.pulseLayer.position = point
}
}
}
} }
/** /**
...@@ -145,6 +73,54 @@ public class MaterialPulseView : MaterialView { ...@@ -145,6 +73,54 @@ public class MaterialPulseView : MaterialView {
shrinkAnimation() shrinkAnimation()
} }
/// Triggers the pulse animation.
public func pulse(point: CGPoint) {
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
let v: CGFloat = r / f
let d: CGFloat = 2 * f
let s: CGFloat = 1.05
var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t {
t = 0.55
} else if 0.25 > t {
t = 0.55
}
t /= 1.3
if nil != pulseColor && 0 < pulseColorOpacity {
let pulseLayer: CAShapeLayer = CAShapeLayer()
pulseLayer.hidden = true
pulseLayer.zPosition = 1
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
visualLayer.addSublayer(pulseLayer)
MaterialAnimation.animationDisabled {
pulseLayer.bounds = CGRectMake(0, 0, v, v)
pulseLayer.position = point
pulseLayer.cornerRadius = r / d
pulseLayer.hidden = false
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [unowned self] in
if nil != self.pulseColor && 0 < self.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
pulseLayer.removeFromSuperlayer()
}
}
}
}
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
}
}
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method it is recommended to override the prepareView method
...@@ -155,35 +131,19 @@ public class MaterialPulseView : MaterialView { ...@@ -155,35 +131,19 @@ public class MaterialPulseView : MaterialView {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = MaterialColor.white pulseColor = MaterialColor.white
preparePulseLayer()
}
/// Prepares the pulseLayer property.
internal func preparePulseLayer() {
pulseLayer.hidden = true
pulseLayer.zPosition = 1
visualLayer.addSublayer(pulseLayer)
}
/// Updates the pulseLayer when settings have changed.
internal func updatePulseLayer() {
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
} }
/// Executes the shrink animation for the pulse effect. /// Executes the shrink animation for the pulse effect.
internal func shrinkAnimation() { internal func shrinkAnimation() {
let t: CFTimeInterval = 0.25
let s: CGFloat = 1
if nil != pulseColor && 0 < pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: { [unowned self] in
self.pulseLayer.hidden = true
})
pulseLayer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
}
if pulseScale { if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil) var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t {
t = 0.55
} else if 0.25 > t {
t = 0.55
}
t /= 1.3
layer.addAnimation(MaterialAnimation.scale(1, duration: t), forKey: nil)
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment