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
33b548eb
Commit
33b548eb
authored
Aug 17, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: applying updates to issue-491, second pass
parent
973206a0
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
592 additions
and
615 deletions
+592
-615
Material.xcodeproj/project.pbxproj
+10
-6
Sources/iOS/BottomNavigationController.swift
+20
-20
Sources/iOS/CollectionView.swift
+16
-16
Sources/iOS/CollectionViewCell.swift
+22
-14
Sources/iOS/Depth.swift
+0
-23
Sources/iOS/DynamicFontType.swift
+1
-1
Sources/iOS/Grid.swift
+1
-1
Sources/iOS/JSON.swift
+17
-17
Sources/iOS/Label.swift
+16
-12
Sources/iOS/Layer.swift
+15
-198
Sources/iOS/Material+CALayer.swift
+316
-0
Sources/iOS/Material+UIView.swift
+38
-147
Sources/iOS/MaterialTextLayer.swift
+1
-49
Sources/iOS/NavigationController.swift
+36
-36
Sources/iOS/RootController.swift
+51
-50
Sources/iOS/SearchBarController.swift
+4
-4
Sources/iOS/ToolbarController.swift
+14
-14
Sources/iOS/View.swift
+14
-7
No files found.
Material.xcodeproj/project.pbxproj
View file @
33b548eb
...
...
@@ -55,7 +55,7 @@
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C71CB40DC500C806FE
/* KeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
;
};
96BCB7C81CB40DC500C806FE
/*
MaterialLabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* Material
Label.swift */
;
};
96BCB7C81CB40DC500C806FE
/*
Label.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/*
Label.swift */
;
};
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Layer.swift */
;
};
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
};
96BCB7CB1CB40DC500C806FE
/* PulseAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
;
};
...
...
@@ -159,7 +159,7 @@
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7851CB40DC500C806FE
/* CornerRadius.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7861CB40DC500C806FE
/* Shape.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8541CB4115200C806FE
/*
MaterialLabel.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* Material
Label.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8541CB4115200C806FE
/*
Label.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/*
Label.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7841CB40DC500C806FE
/* PulseView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7881CB40DC500C806FE
/* Switch.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8571CB4115200C806FE
/* View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78C1CB40DC500C806FE
/* View.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -177,6 +177,7 @@
96E3C39E1D3A1D0C0086A024
/* BasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
;
};
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
;
};
96EA9A4B1D4E7A430052C74D
/* PhotoLibraryController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
;
};
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
;
};
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
...
...
@@ -246,7 +247,7 @@
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialGravity.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
KeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/*
MaterialLabel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Material
Label.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/*
Label.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Label.swift
;
sourceTree
=
"<group>"
;
};
96BCB7801CB40DC500C806FE
/* Layer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layer.swift
;
sourceTree
=
"<group>"
;
};
96BCB7811CB40DC500C806FE
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PulseAnimation.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -292,6 +293,7 @@
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibrary.swift
;
sourceTree
=
"<group>"
;
};
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibraryController.swift
;
sourceTree
=
"<group>"
;
};
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+CALayer.swift"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -416,7 +418,7 @@
968C99431D36ECBB000074FF
/* Label */
=
{
isa
=
PBXGroup
;
children
=
(
96BCB77F1CB40DC500C806FE
/*
Material
Label.swift */
,
96BCB77F1CB40DC500C806FE
/* Label.swift */
,
);
name
=
Label
;
sourceTree
=
"<group>"
;
...
...
@@ -607,6 +609,7 @@
children
=
(
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
,
96E3C3931D397AE90086A024
/* Material+UIView.swift */
,
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
,
96BCB7641CB40DC500C806FE
/* Material+String.swift */
,
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
,
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
,
...
...
@@ -746,7 +749,7 @@
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
,
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
,
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
,
96BCB8541CB4115200C806FE
/*
Material
Label.swift in Headers */
,
96BCB8541CB4115200C806FE
/* Label.swift in Headers */
,
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
,
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
,
96BCB8571CB4115200C806FE
/* View.swift in Headers */
,
...
...
@@ -975,7 +978,7 @@
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
,
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
,
96BCB7E91CB40DC500C806FE
/* ToolbarController.swift in Sources */
,
96BCB7C81CB40DC500C806FE
/*
Material
Label.swift in Sources */
,
96BCB7C81CB40DC500C806FE
/* Label.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* CollectionViewDelegate.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
...
...
@@ -1009,6 +1012,7 @@
966ECF2A1CF4C20100BB0BDF
/* CollectionReusableView.swift in Sources */
,
96BCB7E51CB40DC500C806FE
/* TextField.swift in Sources */
,
96BCB7D21CB40DC500C806FE
/* MaterialTableViewCell.swift in Sources */
,
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
,
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
,
96BCB7A71CB40DC500C806FE
/* ControlView.swift in Sources */
,
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
...
...
Sources/iOS/BottomNavigationController.swift
View file @
33b548eb
...
...
@@ -60,23 +60,23 @@ public enum BottomNavigationTransitionAnimation: Int {
}
@IBDesignable
public
class
BottomNavigationController
:
UITabBarController
,
UITabBarControllerDelegate
{
open
class
BottomNavigationController
:
UITabBarController
,
UITabBarControllerDelegate
{
/// The transition animation to use when selecting a new tab.
public
var
transitionAnimation
:
BottomNavigationTransitionAnimation
=
.
fade
open
var
transitionAnimation
:
BottomNavigationTransitionAnimation
=
.
fade
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
}
...
...
@@ -85,17 +85,17 @@ public class BottomNavigationController : UITabBarController, UITabBarController
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
}
public
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
}
public
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
}
public
func
layoutSubviews
()
{
open
func
layoutSubviews
()
{
if
let
v
:
Array
<
UITabBarItem
>
=
tabBar
.
items
{
for
item
in
v
{
if
.
phone
==
Device
.
userInterfaceIdiom
{
...
...
@@ -121,13 +121,13 @@ public class BottomNavigationController : UITabBarController, UITabBarController
}
/**
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
()
{
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.
*/
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
delegate
=
self
...
...
@@ -135,7 +135,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
}
/// Handles transitions when tabBarItems are pressed.
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
open
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
let
fVC
:
UIViewController
?
=
fromVC
let
tVC
:
UIViewController
?
=
toVC
if
nil
==
fVC
||
nil
==
tVC
{
...
...
Sources/iOS/CollectionView.swift
View file @
33b548eb
...
...
@@ -79,28 +79,28 @@ open class CollectionView: UICollectionView {
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public
override
init
(
frame
:
CGRect
,
collectionViewLayout
layout
:
UICollectionViewLayout
)
{
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
layout
)
prepareView
()
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
CollectionViewLayout
())
prepareView
()
...
...
@@ -112,12 +112,12 @@ open class CollectionView: UICollectionView {
}
/**
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.
*/
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.
*/
open
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
backgroundColor
=
Color
.
clear
...
...
Sources/iOS/CollectionViewCell.swift
View file @
33b548eb
...
...
@@ -63,7 +63,8 @@ open class CollectionViewCell: UICollectionViewCell {
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
*/
@IBInspectable
open
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
}
...
...
@@ -75,7 +76,8 @@ open class CollectionViewCell: UICollectionViewCell {
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
*/
@IBInspectable
open
var
contentsRect
:
CGRect
{
@IBInspectable
open
var
contentsRect
:
CGRect
{
get
{
return
visualLayer
.
contentsRect
}
...
...
@@ -88,7 +90,8 @@ open class CollectionViewCell: UICollectionViewCell {
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
*/
@IBInspectable
open
var
contentsCenter
:
CGRect
{
@IBInspectable
open
var
contentsCenter
:
CGRect
{
get
{
return
visualLayer
.
contentsCenter
}
...
...
@@ -102,7 +105,8 @@ open class CollectionViewCell: UICollectionViewCell {
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
*/
@IBInspectable
open
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
get
{
return
visualLayer
.
contentsScale
}
...
...
@@ -119,7 +123,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
open
var
contentsGravity
:
String
{
@IBInspectable
open
var
contentsGravity
:
String
{
get
{
return
visualLayer
.
contentsGravity
}
...
...
@@ -139,7 +144,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
/// A wrapper around grid.contentInset.
@IBInspectable
open
var
contentInset
:
EdgeInsets
{
@IBInspectable
open
var
contentInset
:
EdgeInsets
{
get
{
return
contentView
.
grid
.
contentEdgeInsets
}
...
...
@@ -156,7 +162,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
/// A wrapper around grid.interimSpace.
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
get
{
return
contentView
.
grid
.
interimSpace
}
...
...
@@ -166,7 +173,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
}
...
...
@@ -262,12 +270,12 @@ open class CollectionViewCell: UICollectionViewCell {
}
/**
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.
*/
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.
*/
open
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
prepareVisualLayer
()
...
...
Sources/iOS/Depth.swift
View file @
33b548eb
...
...
@@ -107,26 +107,3 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
5
),
opacity
:
0.3
,
radius
:
5
)
}
}
/// Grid extension for UIView.
extension
UIView
{
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
{
get
{
return
material
.
depthPreset
}
set
(
value
)
{
material
.
depthPreset
=
value
}
}
/// Grid reference.
public
var
depth
:
Depth
{
get
{
return
material
.
depth
}
set
(
value
)
{
material
.
depth
=
value
}
}
}
Sources/iOS/DynamicFontType.swift
View file @
33b548eb
...
...
@@ -41,7 +41,7 @@ public protocol DynamicFontTypeDelegate {
}
@objc(DynamicFontType)
public
class
DynamicFontType
:
NSObject
{
open
class
DynamicFontType
:
NSObject
{
/// A weak reference to a DynamicFontTypeDelegate.
public
weak
var
delegate
:
DynamicFontTypeDelegate
?
...
...
Sources/iOS/Grid.swift
View file @
33b548eb
...
...
@@ -42,7 +42,7 @@ public class GridAxis {
unowned
var
grid
:
Grid
/// The direction the grid lays its views out.
public
var
direction
:
GridAxisDirection
=
.
horizontal
{
open
var
direction
:
GridAxisDirection
=
.
horizontal
{
didSet
{
grid
.
reload
()
}
...
...
Sources/iOS/JSON.swift
View file @
33b548eb
...
...
@@ -30,79 +30,79 @@
import
Foundation
public
class
JSON
:
Equatable
,
CustomStringConvertible
{
open
class
JSON
:
Equatable
,
CustomStringConvertible
{
/**
:name: description
*/
public
var
description
:
String
{
open
var
description
:
String
{
return
JSON
.
stringify
(
object
)
??
"{}"
}
/**
:name: object
*/
public
private(set)
var
object
:
Any
open
private(set)
var
object
:
Any
/**
:name: asArray
*/
public
var
asArray
:
[
Any
]?
{
open
var
asArray
:
[
Any
]?
{
return
object
as?
[
Any
]
}
/**
:name: asDictionary
*/
public
var
asDictionary
:
[
String
:
Any
]?
{
open
var
asDictionary
:
[
String
:
Any
]?
{
return
object
as?
[
String
:
Any
]
}
/**
:name: asString
*/
public
var
asString
:
String
?
{
open
var
asString
:
String
?
{
return
object
as?
String
}
/**
:name: asInt
*/
public
var
asInt
:
Int
?
{
open
var
asInt
:
Int
?
{
return
object
as?
Int
}
/**
:name: asDouble
*/
public
var
asDouble
:
Double
?
{
open
var
asDouble
:
Double
?
{
return
object
as?
Double
}
/**
:name: asFloat
*/
public
var
asFloat
:
Float
?
{
open
var
asFloat
:
Float
?
{
return
object
as?
Float
}
/**
:name: asBool
*/
public
var
asBool
:
Bool
?
{
open
var
asBool
:
Bool
?
{
return
object
as?
Bool
}
/**
:name: asNSData
*/
public
var
asNSData
:
Data
?
{
open
var
asNSData
:
Data
?
{
return
JSON
.
serialize
(
object
:
object
)
}
/**
:name: parse
*/
public
class
func
parse
(
_
data
:
Data
,
options
:
JSONSerialization
.
ReadingOptions
=
.
allowFragments
)
->
JSON
?
{
open
class
func
parse
(
_
data
:
Data
,
options
:
JSONSerialization
.
ReadingOptions
=
.
allowFragments
)
->
JSON
?
{
if
let
object
=
try
?
JSONSerialization
.
jsonObject
(
with
:
data
,
options
:
options
)
{
return
JSON
(
object
)
}
...
...
@@ -112,7 +112,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: parse
*/
public
class
func
parse
(
_
json
:
String
)
->
JSON
?
{
open
class
func
parse
(
_
json
:
String
)
->
JSON
?
{
guard
let
data
=
json
.
data
(
using
:
String
.
Encoding
.
utf8
)
else
{
return
nil
}
...
...
@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: serialize
*/
public
class
func
serialize
(
object
:
Any
)
->
Data
?
{
open
class
func
serialize
(
object
:
Any
)
->
Data
?
{
return
try
?
JSONSerialization
.
data
(
withJSONObject
:
object
,
options
:
[])
}
/**
:name: stringify
*/
public
class
func
stringify
(
_
object
:
Any
)
->
String
?
{
open
class
func
stringify
(
_
object
:
Any
)
->
String
?
{
if
let
o
=
object
as?
JSON
{
return
stringify
(
o
.
object
)
}
else
if
let
data
=
JSON
.
serialize
(
object
:
object
)
{
...
...
@@ -154,7 +154,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: operator [0...count - 1]
*/
public
subscript
(
index
:
Int
)
->
JSON
?
{
open
subscript
(
index
:
Int
)
->
JSON
?
{
if
let
item
=
asArray
{
return
JSON
(
item
[
index
])
}
...
...
@@ -164,7 +164,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: operator [key 1...key n]
*/
public
subscript
(
key
:
String
)
->
JSON
?
{
open
subscript
(
key
:
String
)
->
JSON
?
{
if
let
item
=
asDictionary
{
if
nil
!=
item
[
key
]
{
return
JSON
(
item
[
key
]
!
)
...
...
Sources/iOS/
Material
Label.swift
→
Sources/iOS/Label.swift
View file @
33b548eb
...
...
@@ -31,25 +31,26 @@
import
UIKit
@IBDesignable
public
class
MaterialLabel
:
UILabel
{
open
class
Label
:
UILabel
{
/**
:name: layerClass
*/
public
override
class
var
layerClass
:
AnyClass
{
open
override
class
var
layerClass
:
AnyClass
{
return
MaterialTextLayer
.
self
}
/**
:name: textLayer
*/
public
var
textLayer
:
MaterialTextLayer
{
open
var
textLayer
:
MaterialTextLayer
{
return
layer
as!
MaterialTextLayer
}
/**
:name: text
*/
@IBInspectable
public
override
var
text
:
String
?
{
@IBInspectable
open
override
var
text
:
String
?
{
didSet
{
textLayer
.
text
=
text
}
...
...
@@ -58,7 +59,8 @@ public class MaterialLabel : UILabel {
/**
:name: textColor
*/
@IBInspectable
public
override
var
textColor
:
UIColor
?
{
@IBInspectable
open
override
var
textColor
:
UIColor
?
{
didSet
{
textLayer
.
textColor
=
textColor
}
...
...
@@ -67,7 +69,7 @@ public class MaterialLabel : UILabel {
/**
:name: font
*/
public
override
var
font
:
UIFont
!
{
open
override
var
font
:
UIFont
!
{
didSet
{
textLayer
.
fontType
=
font
}
...
...
@@ -76,7 +78,7 @@ public class MaterialLabel : UILabel {
/**
:name: textAlignment
*/
public
override
var
textAlignment
:
NSTextAlignment
{
open
override
var
textAlignment
:
NSTextAlignment
{
didSet
{
textLayer
.
textAlignment
=
textAlignment
}
...
...
@@ -85,7 +87,8 @@ public class MaterialLabel : UILabel {
/**
:name: wrapped
*/
@IBInspectable
public
var
wrapped
:
Bool
{
@IBInspectable
open
var
wrapped
:
Bool
{
didSet
{
textLayer
.
isWrapped
=
wrapped
}
...
...
@@ -94,7 +97,8 @@ public class MaterialLabel : UILabel {
/**
:name: contentsScale
*/
@IBInspectable
public
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
didSet
{
textLayer
.
contentsScale
=
contentsScale
}
...
...
@@ -103,7 +107,7 @@ public class MaterialLabel : UILabel {
/**
:name: lineBreakMode
*/
public
override
var
lineBreakMode
:
NSLineBreakMode
{
open
override
var
lineBreakMode
:
NSLineBreakMode
{
didSet
{
textLayer
.
lineBreakMode
=
lineBreakMode
}
...
...
@@ -139,14 +143,14 @@ public class MaterialLabel : UILabel {
/**
:name: stringSize
*/
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
open
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
return
textLayer
.
stringSize
(
constrainedToWidth
:
width
)
}
/**
:name: prepareView
*/
public
func
prepareView
()
{
open
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
textAlignment
=
.
left
}
...
...
Sources/iOS/Layer.swift
View file @
33b548eb
...
...
@@ -34,77 +34,22 @@ import UIKit
public
protocol
MaterialDelegate
{}
@objc(Layer)
public
class
Layer
:
CAShapeLayer
{
open
class
Layer
:
CAShapeLayer
{
/**
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)
var
visualLayer
:
CAShapeLayer
!
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
}
}
/**
A property that accesses the layer.frame.size.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.
*/
@IBInspectable
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
}
}
}
/**
A property that accesses the layer.frame.size.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.
*/
@IBInspectable
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
}
}
}
open
private(set)
var
visualLayer
:
CAShapeLayer
!
/**
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.
*/
@IBInspectable
public
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
}
...
...
@@ -116,7 +61,7 @@ public class Layer: CAShapeLayer {
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
*/
public
override
var
contentsRect
:
CGRect
{
open
override
var
contentsRect
:
CGRect
{
didSet
{
visualLayer
.
contentsRect
=
contentsRect
}
...
...
@@ -126,7 +71,7 @@ public class Layer: CAShapeLayer {
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
*/
public
override
var
contentsCenter
:
CGRect
{
open
override
var
contentsCenter
:
CGRect
{
didSet
{
visualLayer
.
contentsCenter
=
contentsCenter
}
...
...
@@ -137,21 +82,23 @@ public class Layer: CAShapeLayer {
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the Device.scale.
*/
@IBInspectable
public
override
var
contentsScale
:
CGFloat
{
@IBInspectable
open
override
var
contentsScale
:
CGFloat
{
didSet
{
visualLayer
.
contentsScale
=
contentsScale
}
}
/// A Preset for the contentsGravity property.
public
var
contentsGravityPreset
:
MaterialGravity
{
open
var
contentsGravityPreset
:
MaterialGravity
{
didSet
{
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
public
override
var
contentsGravity
:
String
{
@IBInspectable
open
override
var
contentsGravity
:
String
{
get
{
return
visualLayer
.
contentsGravity
}
...
...
@@ -160,52 +107,13 @@ public class Layer: CAShapeLayer {
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable
public
var
isShadowPathAutoSizing
:
Bool
=
true
{
didSet
{
if
isShadowPathAutoSizing
{
layoutShadowPath
()
}
}
}
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
=
.
none
{
didSet
{
depth
=
DepthPresetToValue
(
preset
:
depthPreset
)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer.
*/
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offset
.
asSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
}
}
/**
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
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/**
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.
*/
@IBInspectable
public
override
var
cornerRadius
:
CGFloat
{
@IBInspectable
open
override
var
cornerRadius
:
CGFloat
{
didSet
{
layoutShadowPath
()
if
.
circle
==
shapePreset
{
...
...
@@ -215,31 +123,6 @@ public class Layer: CAShapeLayer {
}
/**
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
shapePreset
:
ShapePreset
=
.
none
{
didSet
{
if
.
none
!=
shapePreset
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
{
frame
.
size
.
height
=
width
}
layoutShadowPath
()
}
}
}
/// A preset property to set the borderWidth.
public
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
...
...
@@ -276,58 +159,15 @@ public class Layer: CAShapeLayer {
self
.
frame
=
frame
}
public
override
func
layoutSublayers
()
{
open
override
func
layoutSublayers
()
{
super
.
layoutSublayers
()
layoutShape
()
layoutVisualLayer
()
layoutShadowPath
()
}
/**
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
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
}
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: 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
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
}
/// Prepares the visualLayer property.
public
func
prepareVisualLayer
()
{
open
func
prepareVisualLayer
()
{
visualLayer
=
CAShapeLayer
()
visualLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
true
...
...
@@ -339,27 +179,4 @@ public class Layer: CAShapeLayer {
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
}
/// Manages the layout for the shape of the layer instance.
internal
func
layoutShape
()
{
if
.
circle
==
shapePreset
{
let
w
=
width
/
2
if
w
!=
cornerRadius
{
cornerRadius
=
w
}
}
}
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
Sources/iOS/Material+CALayer.swift
0 → 100644
View file @
33b548eb
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
open
class
MaterialLayer
{
/// A reference to the UIView.
internal
weak
var
layer
:
CALayer
?
/**
Initializer that takes in a UIView.
- Parameter view: A UIView reference.
*/
internal
init
(
layer
:
CALayer
?)
{
self
.
layer
=
layer
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/// A preset property to set the shape.
open
var
shapePreset
:
ShapePreset
=
.
none
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
=
Depth
.
zero
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
shadowOffset
=
depth
.
offset
.
asSize
v
.
shadowOpacity
=
depth
.
opacity
v
.
shadowRadius
=
depth
.
radius
v
.
layoutShadowPath
()
}
}
/// Enables automatic shadowPath sizing.
open
var
isShadowPathAutoSizing
=
false
{
didSet
{
if
isShadowPathAutoSizing
{
layer
?
.
layoutShadowPath
()
}
}
}
}
/// A memory reference to the MaterialLayer instance for CALayer extensions.
private
var
MaterialLayerKey
:
UInt8
=
0
/// Grid extension for UIView.
extension
CALayer
{
/// MaterialLayer Reference.
internal
var
material
:
MaterialLayer
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
MaterialLayer
(
layer
:
self
)
}
}
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialLayerKey
,
value
:
value
)
}
}
/// A property that accesses the frame.origin.x property.
@IBInspectable
open
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
layoutShadowPath
()
}
}
/// A property that accesses the frame.origin.y property.
@IBInspectable
open
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layoutShadowPath
()
}
}
/// A property that accesses the frame.size.width property.
@IBInspectable
open
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
/// A property that accesses the frame.size.height property.
@IBInspectable
open
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
/**
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.
*/
open
var
shapePreset
:
ShapePreset
{
get
{
return
material
.
shapePreset
}
set
(
value
)
{
material
.
shapePreset
=
value
}
}
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
:
Depth
{
get
{
return
material
.
depth
}
set
(
value
)
{
material
.
depth
=
value
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
return
material
.
isShadowPathAutoSizing
}
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
}
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
return
material
.
cornerRadiusPreset
}
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
return
material
.
borderWidthPreset
}
set
(
value
)
{
material
.
borderWidthPreset
=
value
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
open
func
animate
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
}
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: 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.
*/
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
}
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
if
.
none
!=
shapePreset
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
if
width
>
height
{
frame
.
size
.
height
=
width
}
}
if
.
circle
==
shapePreset
{
cornerRadius
=
width
/
2
}
}
/// Sets the shadow path.
open
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
Sources/iOS/Material+UIView.swift
View file @
33b548eb
...
...
@@ -30,102 +30,16 @@
import
UIKit
open
class
Material
{
/// A reference to the UIView.
internal
weak
var
view
:
UIView
?
/**
Initializer that takes in a UIView.
- Parameter view: A UIView reference.
*/
internal
init
(
view
:
UIView
?)
{
self
.
view
=
view
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/// A preset property to set the shape.
open
var
shapePreset
:
ShapePreset
=
.
none
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
=
Depth
.
zero
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
layer
.
shadowOffset
=
depth
.
offset
.
asSize
v
.
layer
.
shadowOpacity
=
depth
.
opacity
v
.
layer
.
shadowRadius
=
depth
.
radius
v
.
layoutShadowPath
()
}
}
/// Enables automatic shadowPath sizing.
open
var
isShadowPathAutoSizing
=
false
{
didSet
{
if
isShadowPathAutoSizing
{
view
?
.
layoutShadowPath
()
}
}
}
}
/// A memory reference to the Depth instance for UIView extensions.
private
var
MaterialKey
:
UInt8
=
0
/// Grid extension for UIView.
extension
UIView
{
/// Material Reference.
internal
var
material
:
Material
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialKey
)
{
return
Material
(
view
:
self
)
}
}
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialKey
,
value
:
value
)
}
}
/// A property that accesses the frame.origin.x property.
@IBInspectable
open
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
return
layer
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
layoutShadowPath
()
layer
.
x
=
value
}
}
...
...
@@ -133,12 +47,10 @@ extension UIView {
@IBInspectable
open
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
return
layer
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layoutShadowPath
()
layer
.
y
=
value
}
}
...
...
@@ -146,17 +58,10 @@ extension UIView {
@IBInspectable
open
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
return
layer
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
layoutShape
()
}
layoutShadowPath
()
layer
.
width
=
value
}
}
...
...
@@ -164,17 +69,10 @@ extension UIView {
@IBInspectable
open
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
return
layer
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
layoutShape
()
}
layoutShadowPath
()
layer
.
height
=
value
}
}
...
...
@@ -185,13 +83,30 @@ extension UIView {
*/
open
var
shapePreset
:
ShapePreset
{
get
{
return
material
.
shapePreset
return
layer
.
shapePreset
}
set
(
value
)
{
material
.
shapePreset
=
value
layoutShape
()
layoutShadowPath
()
layer
.
shapePreset
=
value
}
}
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
layer
.
depthPreset
}
set
(
value
)
{
layer
.
depthPreset
=
value
}
}
/// Grid reference.
open
var
depth
:
Depth
{
get
{
return
layer
.
depth
}
set
(
value
)
{
layer
.
depth
=
value
}
}
...
...
@@ -258,20 +173,20 @@ extension UIView {
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
return
material
.
isShadowPathAutoSizing
return
layer
.
isShadowPathAutoSizing
}
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
layer
.
isShadowPathAutoSizing
=
value
}
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
return
material
.
cornerRadiusPreset
return
layer
.
cornerRadiusPreset
}
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
layer
.
cornerRadiusPreset
=
value
}
}
...
...
@@ -283,22 +198,16 @@ extension UIView {
}
set
(
value
)
{
layer
.
cornerRadius
=
value
if
.
circle
==
shapePreset
{
shapePreset
=
.
none
}
else
{
layoutShadowPath
()
}
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
return
material
.
borderWidthPreset
return
layer
.
borderWidthPreset
}
set
(
value
)
{
material
.
borderWidthPreset
=
value
layer
.
borderWidthPreset
=
value
}
}
...
...
@@ -394,29 +303,11 @@ extension UIView {
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
if
.
none
!=
shapePreset
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
if
width
>
height
{
frame
.
size
.
height
=
width
}
}
if
.
circle
==
shapePreset
{
layer
.
cornerRadius
=
width
/
2
}
layer
.
layoutShape
()
}
/// Sets the shadow path.
open
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
layer
.
layoutShadowPath
()
}
}
Sources/iOS/MaterialTextLayer.swift
View file @
33b548eb
...
...
@@ -30,7 +30,7 @@
import
UIKit
public
class
MaterialTextLayer
:
CATextLayer
{
public
class
MaterialTextLayer
:
CATextLayer
{
/**
:name: fontType
*/
...
...
@@ -113,54 +113,6 @@ public class MaterialTextLayer : CATextLayer {
}
/**
:name: x
*/
@IBInspectable
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
}
}
/**
:name: y
*/
@IBInspectable
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
}
}
/**
:name: width
*/
@IBInspectable
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
}
}
/**
:name: height
*/
@IBInspectable
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
}
}
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
...
Sources/iOS/NavigationController.swift
View file @
33b548eb
...
...
@@ -31,34 +31,34 @@
import
UIKit
@IBDesignable
public
class
NavigationController
:
UINavigationController
,
UIGestureRecognizerDelegate
{
open
class
NavigationController
:
UINavigationController
,
UIGestureRecognizerDelegate
{
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
/**
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
}
/**
An initializer that initializes the object with a rootViewController.
- Parameter rootViewController: A UIViewController for the rootViewController.
*/
An initializer that initializes the object with a rootViewController.
- Parameter rootViewController: A UIViewController for the rootViewController.
*/
public
override
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
navigationBarClass
:
NavigationBar
.
self
,
toolbarClass
:
nil
)
setViewControllers
([
rootViewController
],
animated
:
false
)
}
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
if
let
v
=
interactivePopGestureRecognizer
{
if
let
x
=
navigationDrawerController
{
...
...
@@ -72,12 +72,12 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
}
public
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
}
public
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
// Load the initial topItem.
if
let
v
=
navigationBar
as?
NavigationBar
{
...
...
@@ -88,25 +88,25 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
/**
Detects the gesture recognizer being used. This is necessary when using
NavigationDrawerController. It eliminates the conflict in panning.
- Parameter gestureRecognizer: A UIGestureRecognizer to detect.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not, true yes, false no.
*/
public
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
Detects the gesture recognizer being used. This is necessary when using
NavigationDrawerController. It eliminates the conflict in panning.
- Parameter gestureRecognizer: A UIGestureRecognizer to detect.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not, true yes, false no.
*/
open
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
return
interactivePopGestureRecognizer
==
gestureRecognizer
&&
nil
!=
navigationBar
.
backItem
}
/**
Delegation method that is called when a new UINavigationItem is about to be pushed.
This is used to prepare the transitions between UIViewControllers on the stack.
- Parameter navigationBar: A UINavigationBar that is used in the NavigationController.
- Parameter item: The UINavigationItem that will be pushed on the stack.
- Returns: A Boolean value that indicates whether to push the item on to the stack or not.
True is yes, false is no.
*/
public
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
Delegation method that is called when a new UINavigationItem is about to be pushed.
This is used to prepare the transitions between UIViewControllers on the stack.
- Parameter navigationBar: A UINavigationBar that is used in the NavigationController.
- Parameter item: The UINavigationItem that will be pushed on the stack.
- Returns: A Boolean value that indicates whether to push the item on to the stack or not.
True is yes, false is no.
*/
open
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
if
let
v
=
navigationBar
as?
NavigationBar
{
let
backButton
=
IconButton
()
backButton
.
pulseColor
=
Color
.
white
...
...
@@ -133,13 +133,13 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
/**
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
()
{
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.
*/
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
...
...
Sources/iOS/RootController.swift
View file @
33b548eb
...
...
@@ -31,9 +31,9 @@
import
UIKit
@IBDesignable
public
class
RootController
:
UIViewController
{
open
class
RootController
:
UIViewController
{
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
open
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
return
Device
.
statusBarStyle
}
...
...
@@ -43,10 +43,11 @@ public class RootController: UIViewController {
}
/**
A Boolean property used to enable and disable interactivity
with the rootViewController.
*/
@IBInspectable
public
var
isUserInteractionEnabled
:
Bool
{
A Boolean property used to enable and disable interactivity
with the rootViewController.
*/
@IBInspectable
open
var
isUserInteractionEnabled
:
Bool
{
get
{
return
rootViewController
.
view
.
isUserInteractionEnabled
}
...
...
@@ -56,64 +57,64 @@ public class RootController: UIViewController {
}
/**
A UIViewController property that references the active
main UIViewController. To swap the rootViewController, it
is recommended to use the transitionFromRootViewController
helper method.
*/
A UIViewController property that references the active
main UIViewController. To swap the rootViewController, it
is recommended to use the transitionFromRootViewController
helper method.
*/
public
internal(set)
var
rootViewController
:
UIViewController
!
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
prepareView
()
}
/**
An initializer for the BarController.
- Parameter rootViewController: The main UIViewController.
*/
An initializer for the BarController.
- Parameter rootViewController: The main UIViewController.
*/
public
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
self
.
rootViewController
=
rootViewController
prepareView
()
}
public
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
}
/**
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter duration: A TimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active rootViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active rootViewController
to the toViewController has completed.
*/
public
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter duration: A TimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active rootViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active rootViewController
to the toViewController has completed.
*/
open
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
rootViewController
.
willMove
(
toParentViewController
:
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
...
...
@@ -136,20 +137,20 @@ public class RootController: UIViewController {
}
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
public
func
layoutSubviews
()
{}
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
open
func
layoutSubviews
()
{}
/**
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
()
{
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.
*/
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
prepareRootViewController
()
...
...
Sources/iOS/SearchBarController.swift
View file @
33b548eb
...
...
@@ -48,16 +48,16 @@ extension UIViewController {
}
}
public
class
SearchBarController
:
RootController
{
open
class
SearchBarController
:
RootController
{
/// Reference to the SearchBar.
public
private(set)
var
searchBar
:
SearchBar
!
open
private(set)
var
searchBar
:
SearchBar
!
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
let
v
:
SearchBar
=
searchBar
{
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
...
...
@@ -81,7 +81,7 @@ public class SearchBarController: RootController {
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
prepareSearchBar
()
}
...
...
Sources/iOS/ToolbarController.swift
View file @
33b548eb
...
...
@@ -68,7 +68,7 @@ public protocol ToolbarControllerDelegate : MaterialDelegate {
}
@objc(ToolbarController)
public
class
ToolbarController
:
RootController
{
open
class
ToolbarController
:
RootController
{
/// Internal reference to the floatingViewController.
private
var
internalFloatingViewController
:
UIViewController
?
...
...
@@ -79,7 +79,7 @@ public class ToolbarController: RootController {
public
weak
var
delegate
:
ToolbarControllerDelegate
?
/// A floating UIViewController.
public
var
floatingViewController
:
UIViewController
?
{
open
var
floatingViewController
:
UIViewController
?
{
get
{
return
internalFloatingViewController
}
...
...
@@ -156,11 +156,11 @@ public class ToolbarController: RootController {
}
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
public
override
func
layoutSubviews
()
{
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
let
v
:
Toolbar
=
toolbar
{
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
...
...
@@ -178,13 +178,13 @@ public class ToolbarController: RootController {
}
/**
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
()
{
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.
*/
open
override
func
prepareView
()
{
super
.
prepareView
()
prepareToolbar
()
}
...
...
Sources/iOS/View.swift
View file @
33b548eb
...
...
@@ -49,7 +49,8 @@ open class View: UIView {
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
*/
@IBInspectable
open
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
}
...
...
@@ -61,7 +62,8 @@ open class View: UIView {
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
*/
@IBInspectable
open
var
contentsRect
:
CGRect
{
@IBInspectable
open
var
contentsRect
:
CGRect
{
get
{
return
visualLayer
.
contentsRect
}
...
...
@@ -74,7 +76,8 @@ open class View: UIView {
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
*/
@IBInspectable
open
var
contentsCenter
:
CGRect
{
@IBInspectable
open
var
contentsCenter
:
CGRect
{
get
{
return
visualLayer
.
contentsCenter
}
...
...
@@ -88,7 +91,8 @@ open class View: UIView {
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
*/
@IBInspectable
open
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
get
{
return
visualLayer
.
contentsScale
}
...
...
@@ -98,14 +102,16 @@ open class View: UIView {
}
/// A Preset for the contentsGravity property.
@IBInspectable
open
var
contentsGravityPreset
:
MaterialGravity
{
@IBInspectable
open
var
contentsGravityPreset
:
MaterialGravity
{
didSet
{
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
open
var
contentsGravity
:
String
{
@IBInspectable
open
var
contentsGravity
:
String
{
get
{
return
visualLayer
.
contentsGravity
}
...
...
@@ -115,7 +121,8 @@ open class View: UIView {
}
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
}
...
...
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