Commit 884b03ab by Daniel Dahan

updated pulse animation

parent af8066c7
......@@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "GraphKit.png",
"filename" : "Graph.png",
"scale" : "1x"
},
{
......
......@@ -41,7 +41,7 @@ class ViewController: UIViewController {
// the comments below.
prepareGeneralCardViewExample()
// prepareCardViewWithoutPulseBackgroundImageExample()
// prepareCardViewWithAlteredAlignmentExample()
// prepareCardViewWithPulseBackgroundImageExample()
// prepareCardViewButtonBarExample()
}
......@@ -145,41 +145,42 @@ class ViewController: UIViewController {
}
/**
:name: prepareCardViewWithAlteredAlignmentExample
:description: An example of the CardView with an altered alignment of the UI elements.
:name: prepareCardViewWithPulseBackgroundImageExample
:description: An example of the CardView with the pulse animation and an added background image.
*/
private func prepareCardViewWithAlteredAlignmentExample() {
private func prepareCardViewWithPulseBackgroundImageExample() {
let cardView: CardView = CardView()
cardView.dividerInset.left = 100
cardView.titleLabelInset.left = 100
cardView.detailLabelInset.left = 100
cardView.pulseColor = MaterialColor.teal.lighten4
cardView.backgroundColor = MaterialColor.blue.base
cardView.divider = false
// Image.
cardView.image = UIImage(named: "GraphKit")?.resize(toHeight: 100)
cardView.contentsGravity = .TopLeft
cardView.image = UIImage(named: "Graph")?.resize(toHeight: 150)
cardView.contentsGravity = .Right
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "GraphKit"
titleLabel.text = "Graph"
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24)
cardView.titleLabel = titleLabel
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build scalable data-driven apps."
detailLabel.text = "Data-Driven Framework"
detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
// LEARN MORE button.
// Favorite button.
let img1: UIImage? = UIImage(named: "ic_favorite_white")
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.teal.lighten1
btn1.pulseColor = MaterialColor.white
btn1.pulseScale = false
btn1.setTitle("LEARN MORE", forState: .Normal)
btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal)
btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted)
// Add buttons to right side.
cardView.rightButtons = [btn1]
// Add buttons to left side.
cardView.leftButtons = [btn1]
// To support orientation changes, use MaterialLayout.
view.addSubview(cardView)
......
......@@ -11,8 +11,6 @@
967513F01C13EB69009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513EF1C13EB69009F455A /* ViewController.swift */; };
967513F51C13EB69009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513F41C13EB69009F455A /* Assets.xcassets */; };
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 */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +20,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96FE30341C63ADE900548232 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +33,6 @@
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>"; };
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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96FE30331C63ADE900548232 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +49,6 @@
967513E11C13EB69009F455A = {
isa = PBXGroup;
children = (
96FE30321C63ADE900548232 /* Material.framework */,
967513EC1C13EB69009F455A /* ImageCardView */,
967513EB1C13EB69009F455A /* Products */,
);
......
......@@ -39,8 +39,8 @@ class ViewController: UIViewController {
// Examples of using ImageCardView.
// Uncomment different examples and read
// the comments below.
prepareGeneralImageCardViewExample()
// prepareImageCardViewWithoutDetailLabelAndDividerExample()
// prepareGeneralImageCardViewExample()
prepareImageCardViewWithoutDetailLabelAndDividerExample()
}
/**
......
......@@ -11,8 +11,6 @@
965E8E741C14A4950035A270 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965E8E731C14A4950035A270 /* ViewController.swift */; };
965E8E791C14A4950035A270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 965E8E781C14A4950035A270 /* Assets.xcassets */; };
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 */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +20,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96FE303A1C63B00200548232 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +33,6 @@
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>"; };
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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96FE30391C63B00200548232 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +49,6 @@
965E8E651C14A4950035A270 = {
isa = PBXGroup;
children = (
96FE30381C63B00200548232 /* Material.framework */,
965E8E701C14A4950035A270 /* MaterialButton */,
965E8E6F1C14A4950035A270 /* Products */,
);
......
......@@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "CosmicMindInverted.png",
"filename" : "iTunesArtwork.png",
"scale" : "1x"
},
{
......
......@@ -65,11 +65,11 @@ class ViewController: UIViewController {
materialLayer.shape = .Circle
materialLayer.depth = .Depth2
UIImage.contentsOfURL(NSURL(string: "http://www.cosmicmind.io/CM/CosmicMindInverted.png")!) { (image: UIImage?, error: NSError?) in
UIImage.contentsOfURL(NSURL(string: "http://www.cosmicmind.io/CM/iTunesArtwork.png")!) { (image: UIImage?, error: NSError?) in
if let v: UIImage = image {
materialLayer.image = v
} else {
materialLayer.image = UIImage(named: "CosmicMindInverted")
materialLayer.image = UIImage(named: "iTunesArtWork")
}
}
......@@ -77,7 +77,9 @@ class ViewController: UIViewController {
view.layer.addSublayer(materialLayer)
// Add a rotate animation.
materialLayer.animate(MaterialAnimation.rotate(3, duration: 3))
MaterialAnimation.delay(3) {
materialLayer.animate(MaterialAnimation.rotate(3, duration: 3))
}
}
}
......@@ -11,8 +11,6 @@
96DB1C611C14AA2800825BE6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DB1C601C14AA2800825BE6 /* ViewController.swift */; };
96DB1C661C14AA2800825BE6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96DB1C651C14AA2800825BE6 /* Assets.xcassets */; };
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 */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +20,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96FE30371C63AFAD00548232 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +33,6 @@
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>"; };
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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96FE30361C63AFAD00548232 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +49,6 @@
96DB1C521C14AA2800825BE6 = {
isa = PBXGroup;
children = (
96FE30351C63AFAD00548232 /* Material.framework */,
96DB1C5D1C14AA2800825BE6 /* MaterialPulseView */,
96DB1C5C1C14AA2800825BE6 /* Products */,
);
......
......@@ -41,8 +41,7 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
// prepareGeneralMaterialPulseViewExample()
prepareMaterialPulseViewAnimationExample()
prepareGeneralMaterialPulseViewExample()
}
/// General preparation statements.
......@@ -52,37 +51,22 @@ class ViewController: UIViewController {
/// Prepares the MaterialPulseView example.
private func prepareGeneralMaterialPulseViewExample() {
let pulseView: MaterialPulseView = MaterialPulseView(frame: CGRectMake(132, 132, 150, 150))
pulseView.image = UIImage(named: "GraphKitAppIcon")
pulseView.shape = .Square
pulseView.depth = .Depth2
pulseView.cornerRadius = .Radius4
let point: CGFloat = (UIScreen.mainScreen().bounds.width - 150) / 2
// Add pulseView to UIViewController.
view.addSubview(pulseView)
}
/// Prepares the MaterialPulseView animation example.
private func prepareMaterialPulseViewAnimationExample() {
let pulseView: MaterialPulseView = MaterialPulseView(frame: CGRectMake(132, 132, 150, 150))
pulseView.image = UIImage(named: "GraphKitAppIcon")
let pulseView: MaterialPulseView = MaterialPulseView(frame: CGRectMake(point, point, 150, 150))
pulseView.image = UIImage(named: "Graph")
pulseView.shape = .Square
pulseView.depth = .Depth2
pulseView.cornerRadius = .Radius3
print(pulseView)
// Add materialView to UIViewController.
// Add pulseView to UIViewController.
view.addSubview(pulseView)
pulseView.animate(MaterialAnimation.rotate(3, duration: 3))
UIView.animateWithDuration(0.5,
delay: 3,
usingSpringWithDamping: 0.6,
initialSpringVelocity: 0,
options: .AllowUserInteraction,
animations: {
pulseView.y = 300
}, completion: nil)
// Trigger the pulse animation.
MaterialAnimation.delay(2) {
pulseView.pulse()
}
}
}
......@@ -2,15 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "FocusAppIcon.png",
"filename" : "Avatar.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Avatar@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Avatar@3x.png",
"scale" : "3x"
}
],
......
......@@ -53,11 +53,12 @@ class ViewController: UIViewController {
/// Prepare the MaterialView.
private func prepareGeneralMaterialViewExample() {
let materialView: MaterialView = MaterialView(frame: CGRectMake(132, 132, 150, 150))
materialView.image = UIImage(named: "FocusAppIcon")
materialView.shape = .Square
let point: CGFloat = (UIScreen.mainScreen().bounds.width - 150) / 2
let materialView: MaterialView = MaterialView(frame: CGRectMake(point, point, 150, 150))
materialView.image = UIImage(named: "Avatar")
materialView.shape = .Circle
materialView.depth = .Depth2
materialView.cornerRadius = .Radius3
// Add materialView to UIViewController.
view.addSubview(materialView)
......@@ -65,23 +66,33 @@ class ViewController: UIViewController {
/// Prepares the MaterialView animation example.
private func prepareMaterialViewAnimationExample() {
let materialView: MaterialView = MaterialView(frame: CGRectMake(132, 132, 150, 150))
materialView.image = UIImage(named: "FocusAppIcon")
materialView.shape = .Square
let point: CGFloat = (UIScreen.mainScreen().bounds.width - 150) / 2
let materialView: MaterialView = MaterialView(frame: CGRectMake(point, point, 150, 150))
materialView.image = UIImage(named: "Avatar")
materialView.shape = .Circle
materialView.depth = .Depth2
materialView.cornerRadius = .Radius3
// Add materialView to UIViewController.
view.addSubview(materialView)
UIView.animateWithDuration(0.5,
delay: 3,
delay: 2,
usingSpringWithDamping: 0.6,
initialSpringVelocity: 0,
options: .AllowUserInteraction,
animations: {
materialView.y = 300
}, completion: nil)
}) { _ in
UIView.animateWithDuration(0.5,
delay: 2,
usingSpringWithDamping: 0.6,
initialSpringVelocity: 0,
options: .AllowUserInteraction,
animations: {
materialView.y = point
}, completion: nil)
}
}
}
......@@ -239,7 +239,7 @@ class ViewController: UIViewController {
/// Prepares a text alignment example.
private func prepareAlignTitleAndDetailLabelToLeftExample() {
let navigationBarView: NavigationBarView = NavigationBarView()
navigationBarView.backgroundColor = MaterialColor.blue.base
navigationBarView.backgroundColor = MaterialColor.deepPurple.base
/*
To lighten the status bar - add the
......
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '1.29.4'
s.version = '1.30.0'
s.license = 'BSD'
s.summary = 'A beautiful graphics framework for Material Design in Swift.'
s.homepage = 'http://cosmicmind.io'
......
......@@ -49,16 +49,16 @@ Material is a growing project and will encounter changes throughout its developm
## A Tour
* [MaterialColor](#materialcolor)
* [SideNavigationViewController](#sidenavigationviewcontroller)
* [NavigationBarView](#navigationbarview)
* [TextField](#textfield)
* [TextView](#textview)
* [MaterialLayer](#materiallayer)
* [MaterialView](#materialview)
* [MaterialPulseView](#materialpulseview)
* [TextField](#textfield)
* [TextView](#textview)
* [FlatButton](#flatbutton)
* [RaisedButton](#raisedbutton)
* [FabButton](#fabbutton)
* [NavigationBarView](#navigationbarview)
* [SideNavigationViewController](#sidenavigationviewcontroller)
* [CardView](#cardview)
* [ImageCardView](#imagecardview)
* [CaptureView](#captureview)
......@@ -86,23 +86,32 @@ MaterialColor is a complete Material Design color library. It uses base color va
[Learn More About MaterialColor](https://github.com/CosmicMind/Material/wiki/MaterialColor)
<a name="sidenavigationviewcontroller"></a>
## SideNavigationViewController
<a name="materiallayer"></a>
## MaterialLayer
The SideNavigationViewController is an app wide navigation pattern. It generally provides overall app navigation with other useful items. Use the Left position for global app navigation, and the Right position for view navigation.
MaterialLayer is a lightweight CAShapeLayer used throughout Material. It is designed to easily take shape, depth, and animations.
![MaterialSideNavigationViewController](http://www.cosmicmind.io/MK/MaterialSideNavigationViewController.gif)
![MaterialMaterialLayer](http://www.cosmicmind.io/MK/MaterialMaterialLayer.gif)
[Learn More About SideNavigationViewController](https://github.com/CosmicMind/Material/wiki/SideNavigationViewController)
[Learn More About MaterialLayer](https://github.com/CosmicMind/Material/wiki/MaterialLayer)
<a name="navigationbarview"></a>
## NavigationBarView
<a name="materialview"></a>
## MaterialView
A NavigationBarView is a fully featured navigation bar that supports orientation changes, background images, title and detail labels, both left and right button sets, and status bar settings.
MaterialView is the base UIView class used throughout Material. Like MaterialLayer, it is designed to easily take shape, depth, and animations. The major difference is that MaterialView has all the added features of the UIView class.
![MaterialNavigationBarView](http://www.cosmicmind.io/MK/MaterialNavigationBarView.gif)
![MaterialMaterialView](http://www.cosmicmind.io/MK/MaterialMaterialView.gif)
[Learn More About NavigationBarView](https://github.com/CosmicMind/Material/wiki/NavigationBarView)
[Learn More About MaterialView](https://github.com/CosmicMind/Material/wiki/MaterialView)
<a name="materialpulseview"></a>
## MaterialPulseView
MaterialPulseView is at the heart of all pulse animations. Any view that subclasses MaterialPulseView instantly inherits the pulse animation with full customizability.
![MaterialMaterialPulseView](http://www.cosmicmind.io/MK/MaterialMaterialPulseView.gif)
[Learn More About MaterialPulseView](https://github.com/CosmicMind/Material/wiki/MaterialPulseView)
<a name="textfield"></a>
## TextField
......@@ -125,33 +134,6 @@ A TextView is an excellent way to improve UX. TextViews offer details that descr
[Learn More About TextView](https://github.com/CosmicMind/Material/wiki/TextView)
<a name="materiallayer"></a>
## MaterialLayer
MaterialLayer is a lightweight CAShapeLayer used throughout Material. It is designed to easily take shape, depth, and animations.
![MaterialMaterialLayer](http://www.cosmicmind.io/MK/MaterialMaterialLayer.gif)
[Learn More About MaterialLayer](https://github.com/CosmicMind/Material/wiki/MaterialLayer)
<a name="materialview"></a>
## MaterialView
MaterialView is the base UIView class used throughout Material. Like MaterialLayer, it is designed to easily take shape, depth, and animations. The major difference is that MaterialView has all the added features of the UIView class.
![MaterialMaterialView](http://www.cosmicmind.io/MK/MaterialMaterialView.gif)
[Learn More About MaterialView](https://github.com/CosmicMind/Material/wiki/MaterialView)
<a name="materialpulseview"></a>
## MaterialPulseView
MaterialPulseView is at the heart of all pulse animations. Any view that subclasses MaterialPulseView instantly inherits the pulse animation with full customizability.
![MaterialMaterialPulseView](http://www.cosmicmind.io/MK/MaterialMaterialPulseView.gif)
[Learn More About MaterialPulseView](https://github.com/CosmicMind/Material/wiki/MaterialPulseView)
<a name="flatbutton"></a>
## FlatButton
......@@ -179,6 +161,24 @@ A FabButton is essential to Material Design's overall look. Below showcases its
[Learn More About FabButton](https://github.com/CosmicMind/Material/wiki/FabButton)
<a name="navigationbarview"></a>
## NavigationBarView
A NavigationBarView is a fully featured navigation bar that supports orientation changes, background images, title and detail labels, both left and right button sets, and status bar settings.
![MaterialNavigationBarView](http://www.cosmicmind.io/MK/MaterialNavigationBarView.gif)
[Learn More About NavigationBarView](https://github.com/CosmicMind/Material/wiki/NavigationBarView)
<a name="sidenavigationviewcontroller"></a>
## SideNavigationViewController
The SideNavigationViewController is an app wide navigation pattern. It generally provides overall app navigation with other useful items. Use the Left position for global app navigation, and the Right position for view navigation.
![MaterialSideNavigationViewController](http://www.cosmicmind.io/MK/MaterialSideNavigationViewController.gif)
[Learn More About SideNavigationViewController](https://github.com/CosmicMind/Material/wiki/SideNavigationViewController)
<a name="cardview"></a>
## CardView
......@@ -194,7 +194,7 @@ Easily remove the pulse animation and add a background image for an entirely new
Adjust the alignment of the UI elements to create different configurations of the CardView.
![MaterialCardViewDataDriven](http://www.cosmicmind.io/MK/MaterialCardViewDataDriven.gif)
![MaterialCardViewDataDriven](http://www.cosmicmind.io/MK/MaterialCardViewFavoritePulse.gif)
CardViews are so flexible they create entirely new components by removing all but certain elements. For example, bellow is a button bar by only setting the button values of the CardView.
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.29.4</string>
<string>1.30.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -366,7 +366,7 @@ public class MaterialButton : UIButton {
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
pulse(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
pulseAnimation(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
}
/**
......@@ -391,8 +391,66 @@ public class MaterialButton : UIButton {
shrinkAnimation()
}
/// Triggers the pulse animation.
public func pulse(point: CGPoint) {
/**
Triggers the pulse animation.
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public func pulse(var point: CGPoint? = nil) {
if nil == point {
point = CGPointMake(CGFloat(width / 2), CGFloat(height / 2))
}
if let v: CFTimeInterval = pulseAnimation(point!) {
MaterialAnimation.delay(v) { [unowned self] in
self.shrinkAnimation()
}
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public func prepareView() {
prepareVisualLayer()
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
pulseColor = MaterialColor.white
pulseColorOpacity = 0.25
}
/// Prepares the visualLayer property.
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
}
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
}
/**
Triggers the pulse animation.
- Parameter point: A point to pulse from.
- Returns: A Ooptional CFTimeInternal if the point exists within
the view. The time internal represents the animation time.
*/
internal func pulseAnimation(point: CGPoint) -> CFTimeInterval? {
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
......@@ -435,44 +493,10 @@ public class MaterialButton : UIButton {
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
return t
}
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public func prepareView() {
prepareVisualLayer()
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
pulseColor = MaterialColor.white
pulseColorOpacity = 0.25
}
/// Prepares the visualLayer property.
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
}
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
return nil
}
/// Executes the shrink animation for the pulse effect.
......
......@@ -48,7 +48,7 @@ public class MaterialPulseView : MaterialView {
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
pulse(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
pulseAnimation(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
}
/**
......@@ -73,8 +73,42 @@ public class MaterialPulseView : MaterialView {
shrinkAnimation()
}
/// Triggers the pulse animation.
public func pulse(point: CGPoint) {
/**
Triggers the pulse animation.
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public func pulse(var point: CGPoint? = nil) {
if nil == point {
point = CGPointMake(CGFloat(width / 2), CGFloat(height / 2))
}
if let v: CFTimeInterval = pulseAnimation(point!) {
MaterialAnimation.delay(v) { [unowned self] in
self.shrinkAnimation()
}
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.white
}
/**
Triggers the pulse animation.
- Parameter point: A point to pulse from.
- Returns: A Ooptional CFTimeInternal if the point exists within
the view. The time internal represents the animation time.
*/
internal func pulseAnimation(point: CGPoint) -> CFTimeInterval? {
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
......@@ -117,20 +151,10 @@ public class MaterialPulseView : MaterialView {
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
return t
}
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.white
return nil
}
/// Executes the shrink animation for the pulse effect.
......
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