Commit 489a97dd by Daniel Dahan

layoutShadowPath added to better performance of animations with depth

parent f1faab07
...@@ -180,6 +180,7 @@ public class MaterialButton : UIButton { ...@@ -180,6 +180,7 @@ public class MaterialButton : UIButton {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -203,6 +204,7 @@ public class MaterialButton : UIButton { ...@@ -203,6 +204,7 @@ public class MaterialButton : UIButton {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -222,6 +224,7 @@ public class MaterialButton : UIButton { ...@@ -222,6 +224,7 @@ public class MaterialButton : UIButton {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
......
...@@ -217,6 +217,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -217,6 +217,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -240,6 +241,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -240,6 +241,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -259,6 +261,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -259,6 +261,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
......
...@@ -165,6 +165,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -165,6 +165,7 @@ public class MaterialLayer : CAShapeLayer {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -188,6 +189,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -188,6 +189,7 @@ public class MaterialLayer : CAShapeLayer {
*/ */
public override var cornerRadius: CGFloat { public override var cornerRadius: CGFloat {
didSet { didSet {
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -207,6 +209,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -207,6 +209,7 @@ public class MaterialLayer : CAShapeLayer {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
...@@ -325,4 +328,9 @@ public class MaterialLayer : CAShapeLayer { ...@@ -325,4 +328,9 @@ public class MaterialLayer : CAShapeLayer {
cornerRadius = width / 2 cornerRadius = width / 2
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
} }
...@@ -173,6 +173,7 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -173,6 +173,7 @@ public class MaterialTableViewCell: UITableViewCell {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -196,6 +197,7 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -196,6 +197,7 @@ public class MaterialTableViewCell: UITableViewCell {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
} }
} }
......
...@@ -223,6 +223,7 @@ public class MaterialView : UIView { ...@@ -223,6 +223,7 @@ public class MaterialView : UIView {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -246,6 +247,7 @@ public class MaterialView : UIView { ...@@ -246,6 +247,7 @@ public class MaterialView : UIView {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -265,6 +267,7 @@ public class MaterialView : UIView { ...@@ -265,6 +267,7 @@ public class MaterialView : UIView {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
......
...@@ -159,6 +159,7 @@ public class TextField : UITextField { ...@@ -159,6 +159,7 @@ public class TextField : UITextField {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -182,6 +183,7 @@ public class TextField : UITextField { ...@@ -182,6 +183,7 @@ public class TextField : UITextField {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -201,6 +203,7 @@ public class TextField : UITextField { ...@@ -201,6 +203,7 @@ public class TextField : UITextField {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
......
...@@ -161,6 +161,7 @@ public class TextView: UITextView { ...@@ -161,6 +161,7 @@ public class TextView: UITextView {
shadowOffset = value.offset shadowOffset = value.offset
shadowOpacity = value.opacity shadowOpacity = value.opacity
shadowRadius = value.radius shadowRadius = value.radius
layoutShadowPath()
} }
} }
...@@ -184,6 +185,7 @@ public class TextView: UITextView { ...@@ -184,6 +185,7 @@ public class TextView: UITextView {
} }
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath()
if .Circle == shape { if .Circle == shape {
shape = .None shape = .None
} }
...@@ -203,6 +205,7 @@ public class TextView: UITextView { ...@@ -203,6 +205,7 @@ public class TextView: UITextView {
} else { } else {
frame.size.height = width frame.size.height = width
} }
layoutShadowPath()
} }
} }
} }
......
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