Commit 489a97dd by Daniel Dahan

layoutShadowPath added to better performance of animations with depth

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