Commit f1faab07 by Daniel Dahan

initial commit for shadowPath fix

parent 6d13b647
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; }; 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; }; 9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; };
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; }; 96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; };
96D528661C81EB9E00D3BDD1 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96D528651C81EB9E00D3BDD1 /* Material.framework */; };
96D528671C81EB9E00D3BDD1 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96D528651C81EB9E00D3BDD1 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -27,6 +29,7 @@ ...@@ -27,6 +29,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96D528671C81EB9E00D3BDD1 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -47,6 +50,7 @@ ...@@ -47,6 +50,7 @@
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; }; 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; }; 9663F9511C7A751D00AF0965 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; }; 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; };
96D528651C81EB9E00D3BDD1 /* 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 */
...@@ -54,6 +58,7 @@ ...@@ -54,6 +58,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96D528661C81EB9E00D3BDD1 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -63,6 +68,7 @@ ...@@ -63,6 +68,7 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96D528651C81EB9E00D3BDD1 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
......
...@@ -192,17 +192,20 @@ public class MaterialButton : UIButton { ...@@ -192,17 +192,20 @@ public class MaterialButton : UIButton {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
if .Circle == shape {
shape = .None
}
} }
} }
...@@ -231,16 +234,22 @@ public class MaterialButton : UIButton { ...@@ -231,16 +234,22 @@ public class MaterialButton : UIButton {
} }
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat = 0 { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -305,6 +314,7 @@ public class MaterialButton : UIButton { ...@@ -305,6 +314,7 @@ public class MaterialButton : UIButton {
if self.layer == layer { if self.layer == layer {
layoutShape() layoutShape()
layoutVisualLayer() layoutVisualLayer()
layoutShadowPath()
} }
} }
...@@ -438,6 +448,11 @@ public class MaterialButton : UIButton { ...@@ -438,6 +448,11 @@ public class MaterialButton : UIButton {
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
/** /**
Triggers the pulse animation. Triggers the pulse animation.
- Parameter point: A point to pulse from. - Parameter point: A point to pulse from.
......
...@@ -229,17 +229,20 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -229,17 +229,20 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
if .Circle == shape {
shape = .None
}
} }
} }
...@@ -260,17 +263,30 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -260,17 +263,30 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
} }
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset)
}
}
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -302,7 +318,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -302,7 +318,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
depth = .None depth = .None
cornerRadiusPreset = .None cornerRadiusPreset = .None
shape = .None shape = .None
borderWidth = 0
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -317,7 +332,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -317,7 +332,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
depth = .None depth = .None
cornerRadiusPreset = .None cornerRadiusPreset = .None
shape = .None shape = .None
borderWidth = 0
super.init(frame: frame) super.init(frame: frame)
prepareView() prepareView()
} }
...@@ -333,6 +347,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -333,6 +347,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
if self.layer == layer { if self.layer == layer {
layoutShape() layoutShape()
layoutVisualLayer() layoutVisualLayer()
layoutShadowPath()
} }
} }
...@@ -467,6 +482,11 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -467,6 +482,11 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
/** /**
Triggers the pulse animation. Triggers the pulse animation.
- Parameter point: A point to pulse from. - Parameter point: A point to pulse from.
......
...@@ -177,9 +177,6 @@ public class MaterialLayer : CAShapeLayer { ...@@ -177,9 +177,6 @@ public class MaterialLayer : CAShapeLayer {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
......
...@@ -190,9 +190,12 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -190,9 +190,12 @@ public class MaterialTableViewCell: UITableViewCell {
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
} }
} }
...@@ -204,16 +207,22 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -204,16 +207,22 @@ public class MaterialTableViewCell: UITableViewCell {
} }
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat = 0 { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -261,6 +270,7 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -261,6 +270,7 @@ public class MaterialTableViewCell: UITableViewCell {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
layoutVisualLayer() layoutVisualLayer()
layoutShadowPath()
} }
} }
...@@ -392,6 +402,11 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -392,6 +402,11 @@ public class MaterialTableViewCell: UITableViewCell {
visualLayer.cornerRadius = layer.cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
/** /**
Triggers the pulse animation. Triggers the pulse animation.
- Parameter point: A point to pulse from. - Parameter point: A point to pulse from.
......
...@@ -235,17 +235,20 @@ public class MaterialView : UIView { ...@@ -235,17 +235,20 @@ public class MaterialView : UIView {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
if .Circle == shape {
shape = .None
}
} }
} }
...@@ -274,16 +277,22 @@ public class MaterialView : UIView { ...@@ -274,16 +277,22 @@ public class MaterialView : UIView {
} }
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat = 0 { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -346,6 +355,7 @@ public class MaterialView : UIView { ...@@ -346,6 +355,7 @@ public class MaterialView : UIView {
if self.layer == layer { if self.layer == layer {
layoutShape() layoutShape()
layoutVisualLayer() layoutVisualLayer()
layoutShadowPath()
} }
} }
...@@ -430,4 +440,9 @@ public class MaterialView : UIView { ...@@ -430,4 +440,9 @@ public class MaterialView : UIView {
layer.cornerRadius = width / 2 layer.cornerRadius = width / 2
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
} }
...@@ -650,7 +650,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -650,7 +650,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
toggleStatusBar(true) toggleStatusBar(true)
showView(v) showView(v)
hideDepth(v) showDepth(v)
delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Right) delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Right)
case .Changed: case .Changed:
...@@ -685,7 +685,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -685,7 +685,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
toggleStatusBar(true) toggleStatusBar(true)
showView(v) showView(v)
hideDepth(v) showDepth(v)
delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Left) delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Left)
case .Changed: case .Changed:
......
...@@ -171,17 +171,20 @@ public class TextField : UITextField { ...@@ -171,17 +171,20 @@ public class TextField : UITextField {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
if .Circle == shape {
shape = .None
}
} }
} }
...@@ -210,16 +213,22 @@ public class TextField : UITextField { ...@@ -210,16 +213,22 @@ public class TextField : UITextField {
} }
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat = 0 { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -413,6 +422,7 @@ public class TextField : UITextField { ...@@ -413,6 +422,7 @@ public class TextField : UITextField {
if self.layer == layer { if self.layer == layer {
bottomBorderLayer.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, 1) bottomBorderLayer.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, 1)
layoutShape() layoutShape()
layoutShadowPath()
} }
} }
...@@ -540,6 +550,11 @@ public class TextField : UITextField { ...@@ -540,6 +550,11 @@ public class TextField : UITextField {
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
/// Prepares the titleLabel property. /// Prepares the titleLabel property.
private func prepareTitleLabel() { private func prepareTitleLabel() {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
......
...@@ -173,17 +173,20 @@ public class TextView: UITextView { ...@@ -173,17 +173,20 @@ public class TextView: UITextView {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
/// A property that accesses the layer.cornerRadius. /// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 { public var cornerRadius: CGFloat {
didSet { get {
layer.cornerRadius = cornerRadius return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
if .Circle == shape {
shape = .None
}
} }
} }
...@@ -212,16 +215,22 @@ public class TextView: UITextView { ...@@ -212,16 +215,22 @@ public class TextView: UITextView {
} }
/// A property that accesses the layer.borderWith. /// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat = 0 { public var borderWidth: CGFloat {
didSet { get {
layer.borderWidth = borderWidth return layer.borderWidth
}
set(value) {
layer.borderWidth = value
} }
} }
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? { public var borderColor: UIColor? {
didSet { get {
layer.borderColor = borderColor?.CGColor return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
} }
} }
...@@ -358,6 +367,7 @@ public class TextView: UITextView { ...@@ -358,6 +367,7 @@ public class TextView: UITextView {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
layoutShape() layoutShape()
layoutShadowPath()
} }
} }
...@@ -455,6 +465,11 @@ public class TextView: UITextView { ...@@ -455,6 +465,11 @@ public class TextView: UITextView {
} }
} }
/// Sets the shadow path.
internal func layoutShadowPath() {
layer.shadowPath = .None == depth ? nil : UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
}
/** /**
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
......
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