Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
f65afdde
Commit
f65afdde
authored
Jan 02, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MaterialLayer documentation and MaterialButton internals
parent
710ad186
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
212 additions
and
307 deletions
+212
-307
Examples/MaterialKit.xcworkspace/contents.xcworkspacedata
+1
-1
Examples/Programmatic/CardView/CardView.xcodeproj/project.pbxproj
+0
-6
Examples/Programmatic/MaterialLayer/MaterialLayer.xcodeproj/project.pbxproj
+6
-0
Examples/Storyboards/MaterialButton/MaterialButton/ViewController.swift
+0
-0
Sources/FabButton.swift
+9
-16
Sources/FlatButton.swift
+10
-17
Sources/MaterialButton.swift
+100
-90
Sources/MaterialLayer.swift
+72
-62
Sources/MaterialPulseView.swift
+3
-3
Sources/MaterialTheme.swift
+0
-95
Sources/RaisedButton.swift
+11
-17
No files found.
Examples/MaterialKit.xcworkspace/contents.xcworkspacedata
View file @
f65afdde
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
location =
"container:"
location =
"container:"
name =
"MaterialButton"
>
name =
"MaterialButton"
>
<FileRef
<FileRef
location =
"group:
/Users/danieldahan/Dropbox/GraphKit/Technology/Repositories/MaterialKit/Examples/
Storyboards/MaterialButton/MaterialButton.xcodeproj"
>
location =
"group:Storyboards/MaterialButton/MaterialButton.xcodeproj"
>
</FileRef>
</FileRef>
</Group>
</Group>
<Group
<Group
...
...
Examples/Programmatic/CardView/CardView.xcodeproj/project.pbxproj
View file @
f65afdde
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
objects
=
{
objects
=
{
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
960B23541C3870A500E96216
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23531C3870A500E96216
/* MaterialKit.framework */
;
};
960B23551C3870A500E96216
/* MaterialKit.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23531C3870A500E96216
/* MaterialKit.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
967513CA1C136BB7009F455A
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513C91C136BB7009F455A
/* AppDelegate.swift */
;
};
967513CA1C136BB7009F455A
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513C91C136BB7009F455A
/* AppDelegate.swift */
;
};
967513CC1C136BB7009F455A
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513CB1C136BB7009F455A
/* ViewController.swift */
;
};
967513CC1C136BB7009F455A
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513CB1C136BB7009F455A
/* ViewController.swift */
;
};
967513D11C136BB7009F455A
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513D01C136BB7009F455A
/* Assets.xcassets */
;
};
967513D11C136BB7009F455A
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967513D01C136BB7009F455A
/* Assets.xcassets */
;
};
...
@@ -22,7 +20,6 @@
...
@@ -22,7 +20,6 @@
dstPath
=
""
;
dstPath
=
""
;
dstSubfolderSpec
=
10
;
dstSubfolderSpec
=
10
;
files
=
(
files
=
(
960B23551C3870A500E96216
/* MaterialKit.framework in Embed Frameworks */
,
);
);
name
=
"Embed Frameworks"
;
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
...
@@ -30,7 +27,6 @@
...
@@ -30,7 +27,6 @@
/* End PBXCopyFilesBuildPhase section */
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
960B23531C3870A500E96216
/* MaterialKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
MaterialKit.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"
;
sourceTree
=
"<absolute>"
;
};
967513C61C136BB7009F455A
/* CardView.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
CardView.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
967513C61C136BB7009F455A
/* CardView.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
CardView.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
967513C91C136BB7009F455A
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
967513C91C136BB7009F455A
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
967513CB1C136BB7009F455A
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
967513CB1C136BB7009F455A
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -44,7 +40,6 @@
...
@@ -44,7 +40,6 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
960B23541C3870A500E96216
/* MaterialKit.framework in Frameworks */
,
);
);
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
};
};
...
@@ -54,7 +49,6 @@
...
@@ -54,7 +49,6 @@
967513BD1C136BB7009F455A
=
{
967513BD1C136BB7009F455A
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
960B23531C3870A500E96216
/* MaterialKit.framework */
,
967513C81C136BB7009F455A
/* CardView */
,
967513C81C136BB7009F455A
/* CardView */
,
967513C71C136BB7009F455A
/* Products */
,
967513C71C136BB7009F455A
/* Products */
,
);
);
...
...
Examples/Programmatic/MaterialLayer/MaterialLayer.xcodeproj/project.pbxproj
View file @
f65afdde
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
objects
=
{
objects
=
{
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
9637EB0E1C387F08006D9677
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9637EB0D1C387F08006D9677
/* MaterialKit.framework */
;
};
9637EB0F1C387F08006D9677
/* MaterialKit.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9637EB0D1C387F08006D9677
/* MaterialKit.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
965E8E261C149B530035A270
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E251C149B530035A270
/* AppDelegate.swift */
;
};
965E8E261C149B530035A270
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E251C149B530035A270
/* AppDelegate.swift */
;
};
965E8E281C149B530035A270
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E271C149B530035A270
/* ViewController.swift */
;
};
965E8E281C149B530035A270
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E271C149B530035A270
/* ViewController.swift */
;
};
965E8E2D1C149B530035A270
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E2C1C149B530035A270
/* Assets.xcassets */
;
};
965E8E2D1C149B530035A270
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965E8E2C1C149B530035A270
/* Assets.xcassets */
;
};
...
@@ -20,6 +22,7 @@
...
@@ -20,6 +22,7 @@
dstPath
=
""
;
dstPath
=
""
;
dstSubfolderSpec
=
10
;
dstSubfolderSpec
=
10
;
files
=
(
files
=
(
9637EB0F1C387F08006D9677
/* MaterialKit.framework in Embed Frameworks */
,
);
);
name
=
"Embed Frameworks"
;
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
...
@@ -27,6 +30,7 @@
...
@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
9637EB0D1C387F08006D9677
/* MaterialKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
MaterialKit.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"
;
sourceTree
=
"<absolute>"
;
};
965E8E221C149B530035A270
/* MaterialLayer.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
MaterialLayer.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
965E8E221C149B530035A270
/* MaterialLayer.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
MaterialLayer.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
965E8E251C149B530035A270
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
965E8E251C149B530035A270
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
965E8E271C149B530035A270
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
965E8E271C149B530035A270
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -40,6 +44,7 @@
...
@@ -40,6 +44,7 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
9637EB0E1C387F08006D9677
/* MaterialKit.framework in Frameworks */
,
);
);
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
};
};
...
@@ -49,6 +54,7 @@
...
@@ -49,6 +54,7 @@
965E8E191C149B530035A270
=
{
965E8E191C149B530035A270
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
9637EB0D1C387F08006D9677
/* MaterialKit.framework */
,
965E8E241C149B530035A270
/* MaterialLayer */
,
965E8E241C149B530035A270
/* MaterialLayer */
,
965E8E231C149B530035A270
/* Products */
,
965E8E231C149B530035A270
/* Products */
,
);
);
...
...
Examples/Storyboards/MaterialButton/MaterialButton/ViewController.swift
View file @
f65afdde
Sources/FabButton.swift
View file @
f65afdde
...
@@ -20,24 +20,16 @@ import UIKit
...
@@ -20,24 +20,16 @@ import UIKit
public
class
FabButton
:
MaterialButton
{
public
class
FabButton
:
MaterialButton
{
/**
/**
:name: prepareView
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
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
setTitleColor
(
MaterialTheme
.
fabButton
.
titleLabelColorForNormalState
,
forState
:
.
Normal
)
backgroundColor
=
MaterialColor
.
red
.
darken1
titleLabel
?
.
font
=
MaterialTheme
.
fabButton
.
titleLabelFont
depth
=
.
Depth2
shape
=
.
Circle
userInteractionEnabled
=
MaterialTheme
.
fabButton
.
userInteractionEnabled
backgroundColor
=
MaterialTheme
.
fabButton
.
backgroundColor
pulseColorOpacity
=
MaterialTheme
.
fabButton
.
pulseColorOpacity
pulseColor
=
MaterialTheme
.
fabButton
.
pulseColor
depth
=
MaterialTheme
.
fabButton
.
depth
shadowColor
=
MaterialTheme
.
fabButton
.
shadowColor
zPosition
=
MaterialTheme
.
fabButton
.
zPosition
borderWidth
=
MaterialTheme
.
fabButton
.
borderWidth
borderColor
=
MaterialTheme
.
fabButton
.
bordercolor
contentInsets
=
MaterialTheme
.
fabButton
.
contentInsets
shape
=
MaterialTheme
.
fabButton
.
shape
}
}
}
}
\ No newline at end of file
Sources/FlatButton.swift
View file @
f65afdde
...
@@ -20,25 +20,17 @@ import UIKit
...
@@ -20,25 +20,17 @@ import UIKit
public
class
FlatButton
:
MaterialButton
{
public
class
FlatButton
:
MaterialButton
{
/**
/**
:name: prepareView
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
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
setTitleColor
(
MaterialTheme
.
flatButton
.
titleLabelColorForNormalState
,
forState
:
.
Normal
)
setTitleColor
(
MaterialColor
.
blue
.
accent3
,
forState
:
.
Normal
)
titleLabel
?
.
font
=
MaterialTheme
.
flatButton
.
titleLabelFont
pulseColor
=
MaterialColor
.
blue
.
accent3
cornerRadius
=
.
Radius1
userInteractionEnabled
=
MaterialTheme
.
flatButton
.
userInteractionEnabled
contentInsets
=
.
WideRectangle3
backgroundColor
=
MaterialTheme
.
flatButton
.
backgroundColor
pulseColorOpacity
=
MaterialTheme
.
flatButton
.
pulseColorOpacity
pulseColor
=
MaterialTheme
.
flatButton
.
pulseColor
depth
=
MaterialTheme
.
flatButton
.
depth
shadowColor
=
MaterialTheme
.
flatButton
.
shadowColor
zPosition
=
MaterialTheme
.
flatButton
.
zPosition
cornerRadius
=
MaterialTheme
.
flatButton
.
cornerRadius
borderWidth
=
MaterialTheme
.
flatButton
.
borderWidth
borderColor
=
MaterialTheme
.
flatButton
.
bordercolor
contentInsets
=
MaterialTheme
.
flatButton
.
contentInsets
shape
=
MaterialTheme
.
flatButton
.
shape
}
}
}
}
\ No newline at end of file
Sources/MaterialButton.swift
View file @
f65afdde
...
@@ -21,28 +21,25 @@ import UIKit
...
@@ -21,28 +21,25 @@ import UIKit
@objc(MaterialButton)
@objc(MaterialButton)
public
class
MaterialButton
:
UIButton
{
public
class
MaterialButton
:
UIButton
{
/**
/**
:name: visualLayer
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/
*/
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
/// A CAShapeLayer used in the pulse animation.
:name: pulseLayer
*/
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
/**
:name: delegate
A base delegate reference used when subclassing MaterialView.
*/
*/
public
weak
var
delegate
:
MaterialDelegate
?
public
weak
var
delegate
:
MaterialDelegate
?
/**
/// Sets whether the scaling animation should be used.
:name: pulseScale
*/
public
lazy
var
pulseScale
:
Bool
=
true
public
lazy
var
pulseScale
:
Bool
=
true
/**
/// Enables and disables the spotlight effect.
:name: spotlight
*/
public
var
spotlight
:
Bool
=
false
{
public
var
spotlight
:
Bool
=
false
{
didSet
{
didSet
{
if
spotlight
{
if
spotlight
{
...
@@ -52,7 +49,8 @@ public class MaterialButton : UIButton {
...
@@ -52,7 +49,8 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: pulseFill
Determines if the pulse animation should fill the entire
view.
*/
*/
public
var
pulseFill
:
Bool
=
false
{
public
var
pulseFill
:
Bool
=
false
{
didSet
{
didSet
{
...
@@ -62,18 +60,14 @@ public class MaterialButton : UIButton {
...
@@ -62,18 +60,14 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// The opcaity value for the pulse animation.
:name: pulseColorOpacity
*/
public
var
pulseColorOpacity
:
CGFloat
=
0.25
{
public
var
pulseColorOpacity
:
CGFloat
=
0.25
{
didSet
{
didSet
{
updatePulseLayer
()
updatePulseLayer
()
}
}
}
}
/**
/// The color of the pulse effect.
:name: pulseColor
*/
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
updatePulseLayer
()
updatePulseLayer
()
...
@@ -81,7 +75,10 @@ public class MaterialButton : UIButton {
...
@@ -81,7 +75,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: masksToBounds
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
*/
*/
public
var
masksToBounds
:
Bool
{
public
var
masksToBounds
:
Bool
{
get
{
get
{
...
@@ -92,18 +89,14 @@ public class MaterialButton : UIButton {
...
@@ -92,18 +89,14 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the backing layer's backgroundColor.
:name: backgroundColor
*/
public
override
var
backgroundColor
:
UIColor
?
{
public
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
CGColor
layer
.
backgroundColor
=
backgroundColor
?
.
CGColor
}
}
}
}
/**
/// A property that accesses the layer.frame.origin.x property.
:name: x
*/
public
var
x
:
CGFloat
{
public
var
x
:
CGFloat
{
get
{
get
{
return
layer
.
frame
.
origin
.
x
return
layer
.
frame
.
origin
.
x
...
@@ -113,9 +106,7 @@ public class MaterialButton : UIButton {
...
@@ -113,9 +106,7 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the layer.frame.origin.y property.
:name: y
*/
public
var
y
:
CGFloat
{
public
var
y
:
CGFloat
{
get
{
get
{
return
layer
.
frame
.
origin
.
y
return
layer
.
frame
.
origin
.
y
...
@@ -126,7 +117,10 @@ public class MaterialButton : UIButton {
...
@@ -126,7 +117,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: width
A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/
*/
public
var
width
:
CGFloat
{
public
var
width
:
CGFloat
{
get
{
get
{
...
@@ -141,7 +135,10 @@ public class MaterialButton : UIButton {
...
@@ -141,7 +135,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: height
A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/
*/
public
var
height
:
CGFloat
{
public
var
height
:
CGFloat
{
get
{
get
{
...
@@ -155,18 +152,14 @@ public class MaterialButton : UIButton {
...
@@ -155,18 +152,14 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the backing layer's shadowColor.
:name: shadowColor
*/
public
var
shadowColor
:
UIColor
?
{
public
var
shadowColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
shadowColor
=
shadowColor
?
.
CGColor
layer
.
shadowColor
=
shadowColor
?
.
CGColor
}
}
}
}
/**
/// A property that accesses the backing layer's shadowOffset.
:name: shadowOffset
*/
public
var
shadowOffset
:
CGSize
{
public
var
shadowOffset
:
CGSize
{
get
{
get
{
return
layer
.
shadowOffset
return
layer
.
shadowOffset
...
@@ -176,9 +169,7 @@ public class MaterialButton : UIButton {
...
@@ -176,9 +169,7 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the backing layer's shadowOpacity.
:name: shadowOpacity
*/
public
var
shadowOpacity
:
Float
{
public
var
shadowOpacity
:
Float
{
get
{
get
{
return
layer
.
shadowOpacity
return
layer
.
shadowOpacity
...
@@ -188,9 +179,7 @@ public class MaterialButton : UIButton {
...
@@ -188,9 +179,7 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the backing layer's shadowRadius.
:name: shadowRadius
*/
public
var
shadowRadius
:
CGFloat
{
public
var
shadowRadius
:
CGFloat
{
get
{
get
{
return
layer
.
shadowRadius
return
layer
.
shadowRadius
...
@@ -201,7 +190,9 @@ public class MaterialButton : UIButton {
...
@@ -201,7 +190,9 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: depth
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
*/
public
var
depth
:
MaterialDepth
{
public
var
depth
:
MaterialDepth
{
didSet
{
didSet
{
...
@@ -213,9 +204,11 @@ public class MaterialButton : UIButton {
...
@@ -213,9 +204,11 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: cornerRadius
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/
*/
public
var
cornerRadius
:
MaterialRadius
?
{
public
var
cornerRadius
:
MaterialRadius
{
didSet
{
didSet
{
if
let
v
:
MaterialRadius
=
cornerRadius
{
if
let
v
:
MaterialRadius
=
cornerRadius
{
layer
.
cornerRadius
=
MaterialRadiusToValue
(
v
)
layer
.
cornerRadius
=
MaterialRadiusToValue
(
v
)
...
@@ -227,7 +220,9 @@ public class MaterialButton : UIButton {
...
@@ -227,7 +220,9 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: shape
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
*/
public
var
shape
:
MaterialShape
{
public
var
shape
:
MaterialShape
{
didSet
{
didSet
{
...
@@ -242,7 +237,8 @@ public class MaterialButton : UIButton {
...
@@ -242,7 +237,8 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: borderWidth
A property that accesses the layer.borderWith using a MaterialBorder
enum preset.
*/
*/
public
var
borderWidth
:
MaterialBorder
{
public
var
borderWidth
:
MaterialBorder
{
didSet
{
didSet
{
...
@@ -250,18 +246,14 @@ public class MaterialButton : UIButton {
...
@@ -250,18 +246,14 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the layer.borderColor property.
:name: borderColor
*/
public
var
borderColor
:
UIColor
?
{
public
var
borderColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
borderColor
=
borderColor
?
.
CGColor
layer
.
borderColor
=
borderColor
?
.
CGColor
}
}
}
}
/**
/// A property that accesses the layer.position property.
:name: position
*/
public
var
position
:
CGPoint
{
public
var
position
:
CGPoint
{
get
{
get
{
return
layer
.
position
return
layer
.
position
...
@@ -271,9 +263,7 @@ public class MaterialButton : UIButton {
...
@@ -271,9 +263,7 @@ public class MaterialButton : UIButton {
}
}
}
}
/**
/// A property that accesses the layer.zPosition property.
:name: zPosition
*/
public
var
zPosition
:
CGFloat
{
public
var
zPosition
:
CGFloat
{
get
{
get
{
return
layer
.
zPosition
return
layer
.
zPosition
...
@@ -294,38 +284,41 @@ public class MaterialButton : UIButton {
...
@@ -294,38 +284,41 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: init
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
borderWidth
=
.
None
borderWidth
=
.
None
depth
=
.
None
depth
=
.
None
shape
=
.
None
shape
=
.
None
cornerRadius
=
.
None
contentInsets
=
.
None
contentInsets
=
.
None
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
prepareView
()
}
}
/**
/**
:name: init
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
using the init() initializer.
- Parameter frame: A CGRect instance.
*/
*/
public
override
init
(
frame
:
CGRect
)
{
public
override
init
(
frame
:
CGRect
)
{
borderWidth
=
.
None
borderWidth
=
.
None
depth
=
.
None
depth
=
.
None
shape
=
.
None
shape
=
.
None
cornerRadius
=
.
None
contentInsets
=
.
None
contentInsets
=
.
None
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
prepareView
()
prepareView
()
}
}
/**
:name: init
/// A convenience initializer that is mostly used with AutoLayout.
*/
public
convenience
init
()
{
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectNull
)
self
.
init
(
frame
:
CGRectNull
)
}
}
/**
/// Overriding the layout callback for layer sublayers.
:name: layoutSublayersOfLayer
*/
public
override
func
layoutSublayersOfLayer
(
layer
:
CALayer
)
{
public
override
func
layoutSublayersOfLayer
(
layer
:
CALayer
)
{
super
.
layoutSublayersOfLayer
(
layer
)
super
.
layoutSublayersOfLayer
(
layer
)
if
self
.
layer
==
layer
{
if
self
.
layer
==
layer
{
...
@@ -335,7 +328,9 @@ public class MaterialButton : UIButton {
...
@@ -335,7 +328,9 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: animate
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
*/
public
func
animate
(
animation
:
CAAnimation
)
{
public
func
animate
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
animation
.
delegate
=
self
...
@@ -352,14 +347,21 @@ public class MaterialButton : UIButton {
...
@@ -352,14 +347,21 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: animationDidStart
A delegation method that is executed when the backing layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
anim
)
}
}
/**
/**
:name: animationDidStop
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
*/
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
...
@@ -379,7 +381,10 @@ public class MaterialButton : UIButton {
...
@@ -379,7 +381,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: touchesBegan
A delegation method that is executed when the view has began a
touch event.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
*/
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
)
...
@@ -409,7 +414,10 @@ public class MaterialButton : UIButton {
...
@@ -409,7 +414,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: touchesMoved
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
?)
{
public
override
func
touchesMoved
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesMoved
(
touches
,
withEvent
:
event
)
super
.
touchesMoved
(
touches
,
withEvent
:
event
)
...
@@ -424,7 +432,10 @@ public class MaterialButton : UIButton {
...
@@ -424,7 +432,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: touchesEnded
A delegation method that is executed when the view touch event has
ended.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
...
@@ -432,7 +443,10 @@ public class MaterialButton : UIButton {
...
@@ -432,7 +443,10 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: touchesCancelled
A delegation method that is executed when the view touch event has
been cancelled.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
...
@@ -447,59 +461,55 @@ public class MaterialButton : UIButton {
...
@@ -447,59 +461,55 @@ public class MaterialButton : UIButton {
}
}
/**
/**
:name: prepareView
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
()
{
public
func
prepareView
()
{
prepareVisualLayer
()
prepareVisualLayer
()
preparePulseLayer
()
preparePulseLayer
()
shadowColor
=
MaterialColor
.
black
borderColor
=
MaterialColor
.
black
pulseColor
=
MaterialColor
.
white
pulseColorOpacity
=
0.25
}
}
/**
/// Prepares the visualLayer property.
:name: prepareVisualLayer
*/
internal
func
prepareVisualLayer
()
{
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
0
visualLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
true
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
layer
.
addSublayer
(
visualLayer
)
}
}
/**
/// Manages the layout for the visualLayer property.
:name: layoutVisualLayer
*/
internal
func
layoutVisualLayer
()
{
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
/**
/// Manages the layout for the shape of the view instance.
:name: layoutShape
*/
internal
func
layoutShape
()
{
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
if
.
Circle
==
shape
{
layer
.
cornerRadius
=
width
/
2
layer
.
cornerRadius
=
width
/
2
}
}
}
}
/**
/// Prepares the pulseLayer property.
:name: preparePulseLayer
*/
internal
func
preparePulseLayer
()
{
internal
func
preparePulseLayer
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
visualLayer
.
addSublayer
(
pulseLayer
)
}
}
/**
/// Updates the pulseLayer when settings have changed.
:name: updatePulseLayer
*/
internal
func
updatePulseLayer
()
{
internal
func
updatePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
}
/**
/// Executes the shrink animation for the pulse effect.
:name: shrink
*/
internal
func
shrinkAnimation
()
{
internal
func
shrinkAnimation
()
{
let
t
:
CFTimeInterval
=
0.25
let
t
:
CFTimeInterval
=
0.25
let
s
:
CGFloat
=
1
let
s
:
CGFloat
=
1
...
...
Sources/MaterialLayer.swift
View file @
f65afdde
...
@@ -24,13 +24,14 @@ public protocol MaterialDelegate {}
...
@@ -24,13 +24,14 @@ public protocol MaterialDelegate {}
@objc(MaterialLayer)
@objc(MaterialLayer)
public
class
MaterialLayer
:
CAShapeLayer
{
public
class
MaterialLayer
:
CAShapeLayer
{
/**
/**
:name: visualLayer
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/
*/
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
/// A property that accesses the layer.frame.origin.x property.
:name: x
*/
public
var
x
:
CGFloat
{
public
var
x
:
CGFloat
{
get
{
get
{
return
frame
.
origin
.
x
return
frame
.
origin
.
x
...
@@ -40,9 +41,7 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -40,9 +41,7 @@ public class MaterialLayer : CAShapeLayer {
}
}
}
}
/**
/// A property that accesses the layer.frame.origin.y property.
:name: y
*/
public
var
y
:
CGFloat
{
public
var
y
:
CGFloat
{
get
{
get
{
return
frame
.
origin
.
y
return
frame
.
origin
.
y
...
@@ -53,7 +52,10 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -53,7 +52,10 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: width
A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/
*/
public
var
width
:
CGFloat
{
public
var
width
:
CGFloat
{
get
{
get
{
...
@@ -68,7 +70,10 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -68,7 +70,10 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: height
A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/
*/
public
var
height
:
CGFloat
{
public
var
height
:
CGFloat
{
get
{
get
{
...
@@ -83,56 +88,51 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -83,56 +88,51 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: image
A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
*/
*/
public
var
image
:
UIImage
?
{
public
var
image
:
UIImage
?
{
get
{
didSet
{
return
nil
==
visualLayer
.
contents
?
nil
:
UIImage
(
CGImage
:
visualLayer
.
contents
as!
CGImageRef
)
visualLayer
.
contents
=
image
?
.
CGImage
}
set
(
value
)
{
visualLayer
.
contents
=
value
?
.
CGImage
}
}
}
}
/**
/**
:name: contentsRect
Allows a relative subrectangle within the range of 0 to 1 to be
specified for the visualLayer's contents property. This allows
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
*/
*/
public
override
var
contentsRect
:
CGRect
{
public
override
var
contentsRect
:
CGRect
{
get
{
didSet
{
return
visualLayer
.
contentsRect
}
set
(
value
)
{
visualLayer
.
contentsRect
=
contentsRect
visualLayer
.
contentsRect
=
contentsRect
}
}
}
}
/**
/**
:name: contentsCenter
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
*/
*/
public
override
var
contentsCenter
:
CGRect
{
public
override
var
contentsCenter
:
CGRect
{
get
{
didSet
{
return
visualLayer
.
contentsCenter
}
set
(
value
)
{
visualLayer
.
contentsCenter
=
contentsCenter
visualLayer
.
contentsCenter
=
contentsCenter
}
}
}
}
/**
/**
:name: contentsScale
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the UIScreen's
scale value, UIScreen.mainScreen().scale.
*/
*/
public
override
var
contentsScale
:
CGFloat
{
public
override
var
contentsScale
:
CGFloat
{
get
{
didSet
{
return
visualLayer
.
contentsScale
}
set
(
value
)
{
visualLayer
.
contentsScale
=
contentsScale
visualLayer
.
contentsScale
=
contentsScale
}
}
}
}
/**
/// Determines how content should be aligned within the visualLayer's bounds.
:name: contentsGravity
*/
public
override
var
contentsGravity
:
String
{
public
override
var
contentsGravity
:
String
{
get
{
get
{
return
visualLayer
.
contentsGravity
return
visualLayer
.
contentsGravity
...
@@ -143,7 +143,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -143,7 +143,9 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: depth
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
*/
public
var
depth
:
MaterialDepth
{
public
var
depth
:
MaterialDepth
{
didSet
{
didSet
{
...
@@ -155,7 +157,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -155,7 +157,9 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: cornerRadius
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/
*/
public
override
var
cornerRadius
:
CGFloat
{
public
override
var
cornerRadius
:
CGFloat
{
didSet
{
didSet
{
...
@@ -166,22 +170,25 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -166,22 +170,25 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: shape
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
*/
public
var
shape
:
MaterialShape
{
public
var
shape
:
MaterialShape
{
didSet
{
didSet
{
if
.
None
!=
shape
{
if
.
None
!=
shape
{
if
width
<
height
{
if
width
<
height
{
width
=
height
frame
.
size
.
width
=
height
}
else
{
}
else
{
height
=
width
frame
.
size
.
height
=
width
}
}
}
}
}
}
}
}
/**
/**
:name: init
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
shape
=
.
None
shape
=
.
None
...
@@ -191,7 +198,9 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -191,7 +198,9 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: init
An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures.
- Parameter layer: AnyObject.
*/
*/
public
override
init
(
layer
:
AnyObject
)
{
public
override
init
(
layer
:
AnyObject
)
{
shape
=
.
None
shape
=
.
None
...
@@ -200,9 +209,7 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -200,9 +209,7 @@ public class MaterialLayer : CAShapeLayer {
prepareVisualLayer
()
prepareVisualLayer
()
}
}
/**
/// A convenience initializer.
:name: init
*/
public
override
init
()
{
public
override
init
()
{
shape
=
.
None
shape
=
.
None
depth
=
.
None
depth
=
.
None
...
@@ -211,7 +218,8 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -211,7 +218,8 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: init
An initializer that initializes the object with a CGRect object.
- Parameter frame: A CGRect instance.
*/
*/
public
convenience
init
(
frame
:
CGRect
)
{
public
convenience
init
(
frame
:
CGRect
)
{
self
.
init
()
self
.
init
()
...
@@ -225,7 +233,8 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -225,7 +233,8 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: animate
A method that accepts CAAnimation objects and executes.
- Parameter animation: A CAAnimation instance.
*/
*/
public
func
animate
(
animation
:
CAAnimation
)
{
public
func
animate
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
animation
.
delegate
=
self
...
@@ -242,14 +251,21 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -242,14 +251,21 @@ public class MaterialLayer : CAShapeLayer {
}
}
/**
/**
:name: animationDidStart
A delegation method that is executed when the layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
anim
)
(
delegate
as?
MaterialAnimationDelegate
)?
.
materialAnimationDidStart
?(
anim
)
}
}
/**
/**
:name: animationDidStop
A delegation method that is executed when the layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
*/
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
...
@@ -268,9 +284,7 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -268,9 +284,7 @@ public class MaterialLayer : CAShapeLayer {
layoutVisualLayer
()
layoutVisualLayer
()
}
}
/**
/// Prepares the visualLayer property.
:name: prepareVisualLayer
*/
public
func
prepareVisualLayer
()
{
public
func
prepareVisualLayer
()
{
// visualLayer
// visualLayer
visualLayer
.
zPosition
=
0
visualLayer
.
zPosition
=
0
...
@@ -278,21 +292,17 @@ public class MaterialLayer : CAShapeLayer {
...
@@ -278,21 +292,17 @@ public class MaterialLayer : CAShapeLayer {
addSublayer
(
visualLayer
)
addSublayer
(
visualLayer
)
}
}
/**
/// Manages the layout for the visualLayer property.
:name: layoutShape
*/
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
cornerRadius
=
width
/
2
}
}
/**
:name: layoutVisualLayer
*/
internal
func
layoutVisualLayer
()
{
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
}
/// Manages the layout for the shape of the layer instance.
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
cornerRadius
=
width
/
2
}
}
}
}
Sources/MaterialPulseView.swift
View file @
f65afdde
...
@@ -49,14 +49,14 @@ public class MaterialPulseView : MaterialView {
...
@@ -49,14 +49,14 @@ public class MaterialPulseView : MaterialView {
/// 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
{
didSet
{
update
d
PulseLayer
()
updatePulseLayer
()
}
}
}
}
/// The color of the pulse effect.
/// The color of the pulse effect.
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
update
d
PulseLayer
()
updatePulseLayer
()
}
}
}
}
...
@@ -154,7 +154,7 @@ public class MaterialPulseView : MaterialView {
...
@@ -154,7 +154,7 @@ public class MaterialPulseView : MaterialView {
}
}
/// Updates the pulseLayer when settings have changed.
/// Updates the pulseLayer when settings have changed.
internal
func
update
d
PulseLayer
()
{
internal
func
updatePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
}
...
...
Sources/MaterialTheme.swift
View file @
f65afdde
...
@@ -25,9 +25,6 @@ public struct MaterialTheme {
...
@@ -25,9 +25,6 @@ public struct MaterialTheme {
public
struct
captureView
{}
public
struct
captureView
{}
public
struct
textLayer
{}
public
struct
textLayer
{}
public
struct
label
{}
public
struct
label
{}
public
struct
flatButton
{}
public
struct
raisedButton
{}
public
struct
fabButton
{}
}
}
// basicCardView
// basicCardView
...
@@ -208,95 +205,3 @@ public extension MaterialTheme.label {
...
@@ -208,95 +205,3 @@ public extension MaterialTheme.label {
public
static
var
font
:
UIFont
=
RobotoFont
.
regular
public
static
var
font
:
UIFont
=
RobotoFont
.
regular
}
}
// flatButton
public
extension
MaterialTheme
.
flatButton
{
// shadow
public
static
var
depth
:
MaterialDepth
=
.
None
public
static
var
shadowColor
:
UIColor
=
MaterialColor
.
black
// shape
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius1
public
static
var
contentInsets
:
MaterialEdgeInsets
=
.
WideRectangle3
public
static
var
shape
:
MaterialShape
=
.
None
// border
public
static
var
borderWidth
:
MaterialBorder
=
.
None
public
static
var
bordercolor
:
UIColor
=
MaterialColor
.
black
// color
public
static
var
backgroundColor
:
UIColor
=
MaterialColor
.
clear
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
blue
.
accent3
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
public
static
var
titleLabelColorForNormalState
:
UIColor
=
MaterialColor
.
blue
.
accent3
// interaction
public
static
var
userInteractionEnabled
:
Bool
=
true
// position
public
static
var
zPosition
:
CGFloat
=
200
// font
public
static
var
titleLabelFont
:
UIFont
=
RobotoFont
.
regular
}
// raisedButton
public
extension
MaterialTheme
.
raisedButton
{
// shadow
public
static
var
depth
:
MaterialDepth
=
.
Depth2
public
static
var
shadowColor
:
UIColor
=
MaterialColor
.
black
// shape
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius1
public
static
var
contentInsets
:
MaterialEdgeInsets
=
.
WideRectangle2
public
static
var
shape
:
MaterialShape
=
.
None
// border
public
static
var
borderWidth
:
MaterialBorder
=
.
None
public
static
var
bordercolor
:
UIColor
=
MaterialColor
.
black
// color
public
static
var
backgroundColor
:
UIColor
=
MaterialColor
.
blue
.
accent3
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
public
static
var
titleLabelColorForNormalState
:
UIColor
=
MaterialColor
.
white
// interaction
public
static
var
userInteractionEnabled
:
Bool
=
true
// position
public
static
var
zPosition
:
CGFloat
=
200
// font
public
static
var
titleLabelFont
:
UIFont
=
RobotoFont
.
regular
}
// fabButton
public
extension
MaterialTheme
.
fabButton
{
// shadow
public
static
var
depth
:
MaterialDepth
=
.
Depth2
public
static
var
shadowColor
:
UIColor
=
MaterialColor
.
black
// shape
public
static
var
contentInsets
:
MaterialEdgeInsets
=
.
None
public
static
var
shape
:
MaterialShape
=
.
Circle
// border
public
static
var
borderWidth
:
MaterialBorder
=
.
None
public
static
var
bordercolor
:
UIColor
=
MaterialColor
.
black
// color
public
static
var
backgroundColor
:
UIColor
=
MaterialColor
.
red
.
darken1
public
static
var
pulseColor
:
UIColor
=
MaterialColor
.
white
public
static
var
pulseColorOpacity
:
CGFloat
=
0.25
public
static
var
titleLabelColorForNormalState
:
UIColor
=
MaterialColor
.
white
// interaction
public
static
var
userInteractionEnabled
:
Bool
=
true
// position
public
static
var
zPosition
:
CGFloat
=
200
// font
public
static
var
titleLabelFont
:
UIFont
=
RobotoFont
.
regular
}
Sources/RaisedButton.swift
View file @
f65afdde
...
@@ -20,25 +20,18 @@ import UIKit
...
@@ -20,25 +20,18 @@ import UIKit
public
class
RaisedButton
:
MaterialButton
{
public
class
RaisedButton
:
MaterialButton
{
/**
/**
:name: prepareView
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
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
setTitleColor
(
MaterialTheme
.
raisedButton
.
titleLabelColorForNormalState
,
forState
:
.
Normal
)
setTitleColor
(
MaterialColor
.
white
,
forState
:
.
Normal
)
titleLabel
!.
font
=
MaterialTheme
.
raisedButton
.
titleLabelFont
backgroundColor
=
MaterialColor
.
blue
.
accent3
depth
=
.
Depth2
userInteractionEnabled
=
MaterialTheme
.
raisedButton
.
userInteractionEnabled
cornerRadius
=
.
Radius1
backgroundColor
=
MaterialTheme
.
raisedButton
.
backgroundColor
contentInsets
=
.
WideRectangle3
pulseColorOpacity
=
MaterialTheme
.
raisedButton
.
pulseColorOpacity
pulseColor
=
MaterialTheme
.
raisedButton
.
pulseColor
depth
=
MaterialTheme
.
raisedButton
.
depth
shadowColor
=
MaterialTheme
.
raisedButton
.
shadowColor
zPosition
=
MaterialTheme
.
raisedButton
.
zPosition
cornerRadius
=
MaterialTheme
.
raisedButton
.
cornerRadius
borderWidth
=
MaterialTheme
.
raisedButton
.
borderWidth
borderColor
=
MaterialTheme
.
raisedButton
.
bordercolor
contentInsets
=
MaterialTheme
.
raisedButton
.
contentInsets
shape
=
MaterialTheme
.
raisedButton
.
shape
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment