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
ae0a2079
Unverified
Commit
ae0a2079
authored
Apr 23, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved Motion extension to MotionBasicAnimation
parent
6050b9bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
68 deletions
+115
-68
Sources/iOS/Material+Motion.swift
+12
-12
Sources/iOS/Material+MotionAnimation.swift
+59
-36
Sources/iOS/PageMenuController.swift
+44
-20
No files found.
Sources/iOS/Material+Motion.swift
View file @
ae0a2079
...
@@ -571,38 +571,38 @@ extension MotionAnimator {
...
@@ -571,38 +571,38 @@ extension MotionAnimator {
var
snapshotAnimations
=
[
CABasicAnimation
]()
var
snapshotAnimations
=
[
CABasicAnimation
]()
var
snapshotChildAnimations
=
[
CABasicAnimation
]()
var
snapshotChildAnimations
=
[
CABasicAnimation
]()
let
sizeAnimation
=
Motion
.
size
(
to
.
bounds
.
size
)
let
sizeAnimation
=
Motion
BasicAnimation
.
size
(
to
.
bounds
.
size
)
let
cornerRadiusAnimation
=
Motion
.
corner
(
radius
:
to
.
layer
.
cornerRadius
)
let
cornerRadiusAnimation
=
Motion
BasicAnimation
.
corner
(
radius
:
to
.
layer
.
cornerRadius
)
snapshotAnimations
.
append
(
sizeAnimation
)
snapshotAnimations
.
append
(
sizeAnimation
)
snapshotAnimations
.
append
(
cornerRadiusAnimation
)
snapshotAnimations
.
append
(
cornerRadiusAnimation
)
snapshotAnimations
.
append
(
Motion
.
position
(
to
:
to
.
motionPosition
))
snapshotAnimations
.
append
(
Motion
BasicAnimation
.
position
(
to
:
to
.
motionPosition
))
snapshotAnimations
.
append
(
Motion
.
transform
(
transform
:
to
.
motionTransform
))
snapshotAnimations
.
append
(
Motion
BasicAnimation
.
transform
(
transform
:
to
.
motionTransform
))
snapshotAnimations
.
append
(
Motion
.
background
(
color
:
to
.
backgroundColor
??
.
clear
))
snapshotAnimations
.
append
(
Motion
BasicAnimation
.
background
(
color
:
to
.
backgroundColor
??
.
clear
))
snapshotAnimations
.
append
(
Motion
.
border
(
color
:
to
.
borderColor
??
.
clear
))
snapshotAnimations
.
append
(
Motion
BasicAnimation
.
border
(
color
:
to
.
borderColor
??
.
clear
))
snapshotAnimations
.
append
(
Motion
.
border
(
width
:
to
.
borderWidth
))
snapshotAnimations
.
append
(
Motion
BasicAnimation
.
border
(
width
:
to
.
borderWidth
))
if
let
path
=
to
.
layer
.
shadowPath
{
if
let
path
=
to
.
layer
.
shadowPath
{
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
let
shadowPath
=
Motion
BasicAnimation
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
fromView
.
layer
.
shadowPath
shadowPath
.
fromValue
=
fromView
.
layer
.
shadowPath
snapshotAnimations
.
append
(
shadowPath
)
snapshotAnimations
.
append
(
shadowPath
)
}
}
let
shadowOffset
=
Motion
.
shadow
(
offset
:
to
.
layer
.
shadowOffset
)
let
shadowOffset
=
Motion
BasicAnimation
.
shadow
(
offset
:
to
.
layer
.
shadowOffset
)
shadowOffset
.
fromValue
=
fromView
.
layer
.
shadowOffset
shadowOffset
.
fromValue
=
fromView
.
layer
.
shadowOffset
snapshotAnimations
.
append
(
shadowOffset
)
snapshotAnimations
.
append
(
shadowOffset
)
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
to
.
layer
.
shadowOpacity
)
let
shadowOpacity
=
Motion
BasicAnimation
.
shadow
(
opacity
:
to
.
layer
.
shadowOpacity
)
shadowOpacity
.
fromValue
=
fromView
.
layer
.
shadowOpacity
shadowOpacity
.
fromValue
=
fromView
.
layer
.
shadowOpacity
snapshotAnimations
.
append
(
shadowOpacity
)
snapshotAnimations
.
append
(
shadowOpacity
)
let
shadowRadius
=
Motion
.
shadow
(
radius
:
to
.
layer
.
shadowRadius
)
let
shadowRadius
=
Motion
BasicAnimation
.
shadow
(
radius
:
to
.
layer
.
shadowRadius
)
shadowRadius
.
fromValue
=
fromView
.
layer
.
shadowRadius
shadowRadius
.
fromValue
=
fromView
.
layer
.
shadowRadius
snapshotAnimations
.
append
(
shadowRadius
)
snapshotAnimations
.
append
(
shadowRadius
)
snapshotChildAnimations
.
append
(
cornerRadiusAnimation
)
snapshotChildAnimations
.
append
(
cornerRadiusAnimation
)
snapshotChildAnimations
.
append
(
sizeAnimation
)
snapshotChildAnimations
.
append
(
sizeAnimation
)
snapshotChildAnimations
.
append
(
Motion
.
position
(
x
:
to
.
bounds
.
width
/
2
,
y
:
to
.
bounds
.
height
/
2
))
snapshotChildAnimations
.
append
(
Motion
BasicAnimation
.
position
(
x
:
to
.
bounds
.
width
/
2
,
y
:
to
.
bounds
.
height
/
2
))
let
d
=
calculateAnimationTransitionDuration
(
animations
:
to
.
motionAnimations
)
let
d
=
calculateAnimationTransitionDuration
(
animations
:
to
.
motionAnimations
)
...
...
Sources/iOS/Material+MotionAnimation.swift
View file @
ae0a2079
...
@@ -265,97 +265,97 @@ extension CALayer {
...
@@ -265,97 +265,97 @@ extension CALayer {
case
let
.
custom
(
animation
):
case
let
.
custom
(
animation
):
a
.
append
(
animation
)
a
.
append
(
animation
)
case
let
.
backgroundColor
(
color
):
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
color
))
a
.
append
(
Motion
BasicAnimation
.
background
(
color
:
color
))
case
let
.
barTintColor
(
color
):
case
let
.
barTintColor
(
color
):
a
.
append
(
Motion
.
barTint
(
color
:
color
))
a
.
append
(
Motion
BasicAnimation
.
barTint
(
color
:
color
))
case
let
.
borderColor
(
color
):
case
let
.
borderColor
(
color
):
a
.
append
(
Motion
.
border
(
color
:
color
))
a
.
append
(
Motion
BasicAnimation
.
border
(
color
:
color
))
case
let
.
borderWidth
(
width
):
case
let
.
borderWidth
(
width
):
a
.
append
(
Motion
.
border
(
width
:
width
))
a
.
append
(
Motion
BasicAnimation
.
border
(
width
:
width
))
case
let
.
cornerRadius
(
radius
):
case
let
.
cornerRadius
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
a
.
append
(
Motion
BasicAnimation
.
corner
(
radius
:
radius
))
case
let
.
transform
(
transform
):
case
let
.
transform
(
transform
):
a
.
append
(
Motion
.
transform
(
transform
:
transform
))
a
.
append
(
Motion
BasicAnimation
.
transform
(
transform
:
transform
))
case
let
.
rotationAngle
(
angle
):
case
let
.
rotationAngle
(
angle
):
let
rotate
=
Motion
.
rotation
(
angle
:
angle
)
let
rotate
=
Motion
BasicAnimation
.
rotation
(
angle
:
angle
)
a
.
append
(
rotate
)
a
.
append
(
rotate
)
case
let
.
rotationAngleX
(
angle
):
case
let
.
rotationAngleX
(
angle
):
a
.
append
(
Motion
.
rotationX
(
angle
:
angle
))
a
.
append
(
Motion
BasicAnimation
.
rotationX
(
angle
:
angle
))
case
let
.
rotationAngleY
(
angle
):
case
let
.
rotationAngleY
(
angle
):
a
.
append
(
Motion
.
rotationY
(
angle
:
angle
))
a
.
append
(
Motion
BasicAnimation
.
rotationY
(
angle
:
angle
))
case
let
.
rotationAngleZ
(
angle
):
case
let
.
rotationAngleZ
(
angle
):
a
.
append
(
Motion
.
rotationZ
(
angle
:
angle
))
a
.
append
(
Motion
BasicAnimation
.
rotationZ
(
angle
:
angle
))
case
let
.
spin
(
rotations
):
case
let
.
spin
(
rotations
):
a
.
append
(
Motion
.
spin
(
rotations
:
rotations
))
a
.
append
(
Motion
BasicAnimation
.
spin
(
rotations
:
rotations
))
case
let
.
spinX
(
rotations
):
case
let
.
spinX
(
rotations
):
a
.
append
(
Motion
.
spinX
(
rotations
:
rotations
))
a
.
append
(
Motion
BasicAnimation
.
spinX
(
rotations
:
rotations
))
case
let
.
spinY
(
rotations
):
case
let
.
spinY
(
rotations
):
a
.
append
(
Motion
.
spinY
(
rotations
:
rotations
))
a
.
append
(
Motion
BasicAnimation
.
spinY
(
rotations
:
rotations
))
case
let
.
spinZ
(
rotations
):
case
let
.
spinZ
(
rotations
):
a
.
append
(
Motion
.
spinZ
(
rotations
:
rotations
))
a
.
append
(
Motion
BasicAnimation
.
spinZ
(
rotations
:
rotations
))
case
let
.
scale
(
to
):
case
let
.
scale
(
to
):
a
.
append
(
Motion
.
scale
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
scale
(
to
:
to
))
case
let
.
scaleX
(
to
):
case
let
.
scaleX
(
to
):
a
.
append
(
Motion
.
scaleX
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
scaleX
(
to
:
to
))
case
let
.
scaleY
(
to
):
case
let
.
scaleY
(
to
):
a
.
append
(
Motion
.
scaleY
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
scaleY
(
to
:
to
))
case
let
.
scaleZ
(
to
):
case
let
.
scaleZ
(
to
):
a
.
append
(
Motion
.
scaleZ
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
scaleZ
(
to
:
to
))
case
let
.
translate
(
x
,
y
):
case
let
.
translate
(
x
,
y
):
a
.
append
(
Motion
.
translate
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
a
.
append
(
Motion
BasicAnimation
.
translate
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
translateX
(
to
):
case
let
.
translateX
(
to
):
a
.
append
(
Motion
.
translateX
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
translateX
(
to
:
to
))
case
let
.
translateY
(
to
):
case
let
.
translateY
(
to
):
a
.
append
(
Motion
.
translateY
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
translateY
(
to
:
to
))
case
let
.
translateZ
(
to
):
case
let
.
translateZ
(
to
):
a
.
append
(
Motion
.
translateZ
(
to
:
to
))
a
.
append
(
Motion
BasicAnimation
.
translateZ
(
to
:
to
))
case
.
x
(
_
),
.
y
(
_
),
.
point
(
_
,
_
):
case
.
x
(
_
),
.
y
(
_
),
.
point
(
_
,
_
):
let
position
=
Motion
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
py
))
let
position
=
Motion
BasicAnimation
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
py
))
a
.
append
(
position
)
a
.
append
(
position
)
case
let
.
position
(
x
,
y
):
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
a
.
append
(
Motion
BasicAnimation
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
fade
(
opacity
):
case
let
.
fade
(
opacity
):
let
fade
=
Motion
.
fade
(
opacity
:
opacity
)
let
fade
=
Motion
BasicAnimation
.
fade
(
opacity
:
opacity
)
fade
.
fromValue
=
s
.
value
(
forKey
:
MotionAnimationKeyPath
.
opacity
.
rawValue
)
??
NSNumber
(
floatLiteral
:
1
)
fade
.
fromValue
=
s
.
value
(
forKey
:
MotionAnimationKeyPath
.
opacity
.
rawValue
)
??
NSNumber
(
floatLiteral
:
1
)
a
.
append
(
fade
)
a
.
append
(
fade
)
case
let
.
zPosition
(
index
):
case
let
.
zPosition
(
index
):
let
zPosition
=
Motion
.
zPosition
(
index
:
index
)
let
zPosition
=
Motion
BasicAnimation
.
zPosition
(
index
:
index
)
zPosition
.
fromValue
=
s
.
value
(
forKey
:
MotionAnimationKeyPath
.
zPosition
.
rawValue
)
??
NSNumber
(
integerLiteral
:
0
)
zPosition
.
fromValue
=
s
.
value
(
forKey
:
MotionAnimationKeyPath
.
zPosition
.
rawValue
)
??
NSNumber
(
integerLiteral
:
0
)
a
.
append
(
zPosition
)
a
.
append
(
zPosition
)
case
.
width
(
_
),
.
height
(
_
),
.
size
(
_
,
_
):
case
.
width
(
_
),
.
height
(
_
),
.
size
(
_
,
_
):
a
.
append
(
Motion
.
size
(
CGSize
(
width
:
w
,
height
:
h
)))
a
.
append
(
Motion
BasicAnimation
.
size
(
CGSize
(
width
:
w
,
height
:
h
)))
case
let
.
shadowPath
(
path
):
case
let
.
shadowPath
(
path
):
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
let
shadowPath
=
Motion
BasicAnimation
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
s
.
shadowPath
shadowPath
.
fromValue
=
s
.
shadowPath
a
.
append
(
shadowPath
)
a
.
append
(
shadowPath
)
case
let
.
shadowOffset
(
offset
):
case
let
.
shadowOffset
(
offset
):
let
shadowOffset
=
Motion
.
shadow
(
offset
:
offset
)
let
shadowOffset
=
Motion
BasicAnimation
.
shadow
(
offset
:
offset
)
shadowOffset
.
fromValue
=
s
.
shadowOffset
shadowOffset
.
fromValue
=
s
.
shadowOffset
a
.
append
(
shadowOffset
)
a
.
append
(
shadowOffset
)
case
let
.
shadowOpacity
(
opacity
):
case
let
.
shadowOpacity
(
opacity
):
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
opacity
)
let
shadowOpacity
=
Motion
BasicAnimation
.
shadow
(
opacity
:
opacity
)
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
a
.
append
(
shadowOpacity
)
a
.
append
(
shadowOpacity
)
case
let
.
shadowRadius
(
radius
):
case
let
.
shadowRadius
(
radius
):
let
shadowRadius
=
Motion
.
shadow
(
radius
:
radius
)
let
shadowRadius
=
Motion
BasicAnimation
.
shadow
(
radius
:
radius
)
shadowRadius
.
fromValue
=
s
.
shadowRadius
shadowRadius
.
fromValue
=
s
.
shadowRadius
a
.
append
(
shadowRadius
)
a
.
append
(
shadowRadius
)
case
let
.
depth
(
offset
,
opacity
,
radius
):
case
let
.
depth
(
offset
,
opacity
,
radius
):
if
let
path
=
s
.
shadowPath
{
if
let
path
=
s
.
shadowPath
{
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
let
shadowPath
=
Motion
BasicAnimation
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
s
.
shadowPath
shadowPath
.
fromValue
=
s
.
shadowPath
a
.
append
(
shadowPath
)
a
.
append
(
shadowPath
)
}
}
let
shadowOffset
=
Motion
.
shadow
(
offset
:
offset
)
let
shadowOffset
=
Motion
BasicAnimation
.
shadow
(
offset
:
offset
)
shadowOffset
.
fromValue
=
s
.
shadowOffset
shadowOffset
.
fromValue
=
s
.
shadowOffset
a
.
append
(
shadowOffset
)
a
.
append
(
shadowOffset
)
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
opacity
)
let
shadowOpacity
=
Motion
BasicAnimation
.
shadow
(
opacity
:
opacity
)
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
a
.
append
(
shadowOpacity
)
a
.
append
(
shadowOpacity
)
let
shadowRadius
=
Motion
.
shadow
(
radius
:
radius
)
let
shadowRadius
=
Motion
BasicAnimation
.
shadow
(
radius
:
radius
)
shadowRadius
.
fromValue
=
s
.
shadowRadius
shadowRadius
.
fromValue
=
s
.
shadowRadius
a
.
append
(
shadowRadius
)
a
.
append
(
shadowRadius
)
default
:
break
default
:
break
...
@@ -462,7 +462,30 @@ extension CABasicAnimation {
...
@@ -462,7 +462,30 @@ extension CABasicAnimation {
}
}
}
}
extension
Motion
{
extension
CAKeyframeAnimation
{
/**
A convenience initializer that takes a given MotionAnimationKeyPath.
- Parameter keyPath: An MotionAnimationKeyPath.
*/
public
convenience
init
(
keyPath
:
MotionAnimationKeyPath
)
{
self
.
init
(
keyPath
:
keyPath
.
rawValue
)
}
}
public
struct
MotionKeyframeAnimation
{
/**
Creates a CABasicAnimation for the backgroundColor key path.
- Parameter color: A UIColor.
- Returns: A CABasicAnimation.
*/
public
static
func
background
(
color
:
UIColor
)
->
CAKeyframeAnimation
{
let
animation
=
CAKeyframeAnimation
(
keyPath
:
.
backgroundColor
)
animation
.
values
=
[
color
.
cgColor
]
return
animation
}
}
public
struct
MotionBasicAnimation
{
/**
/**
Creates a CABasicAnimation for the backgroundColor key path.
Creates a CABasicAnimation for the backgroundColor key path.
- Parameter color: A UIColor.
- Parameter color: A UIColor.
...
...
Sources/iOS/PageMenuController.swift
View file @
ae0a2079
...
@@ -110,6 +110,7 @@ open class PageMenuController: UIViewController {
...
@@ -110,6 +110,7 @@ open class PageMenuController: UIViewController {
}
}
prepareViewControllers
()
prepareViewControllers
()
prepareTabBar
()
layoutSubviews
()
layoutSubviews
()
}
}
}
}
...
@@ -133,7 +134,11 @@ open class PageMenuController: UIViewController {
...
@@ -133,7 +134,11 @@ open class PageMenuController: UIViewController {
fileprivate
var
previousContentOffset
:
CGFloat
=
0
fileprivate
var
previousContentOffset
:
CGFloat
=
0
/// The number of views used in the scrollViewPool.
/// The number of views used in the scrollViewPool.
fileprivate
let
viewPoolCount
=
3
open
var
viewPoolCount
=
3
{
didSet
{
layoutSubviews
()
}
}
/**
/**
An initializer that accepts an Array of UIViewControllers.
An initializer that accepts an Array of UIViewControllers.
...
@@ -177,6 +182,7 @@ open class PageMenuController: UIViewController {
...
@@ -177,6 +182,7 @@ open class PageMenuController: UIViewController {
view
.
contentScaleFactor
=
Screen
.
scale
view
.
contentScaleFactor
=
Screen
.
scale
prepareScrollView
()
prepareScrollView
()
prepareViewControllers
()
prepareViewControllers
()
prepareTabBar
()
}
}
}
}
...
@@ -218,8 +224,6 @@ extension PageMenuController {
...
@@ -218,8 +224,6 @@ extension PageMenuController {
prepareViewController
(
at
:
selectedIndex
-
1
)
prepareViewController
(
at
:
selectedIndex
-
1
)
prepareViewController
(
at
:
selectedIndex
+
1
)
prepareViewController
(
at
:
selectedIndex
+
1
)
}
}
prepareTabBar
()
}
}
/**
/**
...
@@ -284,19 +288,32 @@ extension PageMenuController {
...
@@ -284,19 +288,32 @@ extension PageMenuController {
vc
.
view
.
contentScaleFactor
=
Screen
.
scale
vc
.
view
.
contentScaleFactor
=
Screen
.
scale
scrollView
.
addSubview
(
vc
.
view
)
scrollView
.
addSubview
(
vc
.
view
)
}
}
/**
Transitions from one view controller to another.
- Parameter from: The index of the view controller to transition from.
- Parameter to: The index of the view controller to transition to.
*/
fileprivate
func
prepareViewControllersForTransition
(
from
:
Int
,
to
:
Int
)
{
let
fromVC
=
viewControllers
[
from
]
let
toVC
=
viewControllers
[
to
]
fromVC
.
present
(
toVC
,
animated
:
true
)
}
}
}
extension
PageMenuController
{
extension
PageMenuController
{
fileprivate
func
layoutScrollView
()
{
fileprivate
func
layoutScrollView
()
{
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
*
CGFloat
(
viewControllers
.
count
),
height
:
scrollView
.
height
)
let
w
=
view
.
bounds
.
width
scrollView
.
contentOffset
=
CGPoint
(
x
:
scrollView
.
width
*
CGFloat
(
selectedIndex
),
y
:
0
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
*
CGFloat
(
viewControllers
.
count
),
height
:
scrollView
.
height
)
scrollView
.
contentOffset
=
CGPoint
(
x
:
w
*
CGFloat
(
selectedIndex
),
y
:
0
)
guard
let
v
=
tabBar
else
{
guard
let
v
=
tabBar
else
{
scrollView
.
frame
=
view
.
bounds
scrollView
.
frame
=
view
.
bounds
return
return
}
}
let
p
=
tabBar
?
.
height
??
0
let
p
=
v
.
height
let
y
=
view
.
height
-
p
let
y
=
view
.
height
-
p
switch
tabBarAlignment
{
switch
tabBarAlignment
{
...
@@ -310,6 +327,8 @@ extension PageMenuController {
...
@@ -310,6 +327,8 @@ extension PageMenuController {
scrollView
.
y
=
0
scrollView
.
y
=
0
scrollView
.
height
=
view
.
height
scrollView
.
height
=
view
.
height
}
}
scrollView
.
width
=
w
}
}
fileprivate
func
layoutViewControllers
()
{
fileprivate
func
layoutViewControllers
()
{
...
@@ -344,7 +363,8 @@ extension PageMenuController {
...
@@ -344,7 +363,8 @@ extension PageMenuController {
- Parameter position: An Int for the position of the view controller.
- Parameter position: An Int for the position of the view controller.
*/
*/
fileprivate
func
layoutViewController
(
at
index
:
Int
,
position
:
Int
)
{
fileprivate
func
layoutViewController
(
at
index
:
Int
,
position
:
Int
)
{
viewControllers
[
index
]
.
view
.
frame
=
CGRect
(
x
:
CGFloat
(
position
)
*
scrollView
.
width
,
y
:
0
,
width
:
scrollView
.
width
,
height
:
scrollView
.
height
)
let
w
=
scrollView
.
width
viewControllers
[
index
]
.
view
.
frame
=
CGRect
(
x
:
CGFloat
(
position
)
*
w
,
y
:
0
,
width
:
w
,
height
:
scrollView
.
height
)
}
}
/**
/**
...
@@ -355,20 +375,20 @@ extension PageMenuController {
...
@@ -355,20 +375,20 @@ extension PageMenuController {
return
return
}
}
let
p
=
tabBar
?
.
height
??
0
let
p
=
v
.
height
let
y
=
view
.
height
-
p
let
y
=
view
.
height
-
p
tabBar
?
.
width
=
view
.
width
v
.
width
=
view
.
width
switch
tabBarAlignment
{
switch
tabBarAlignment
{
case
.
top
:
case
.
top
:
tabBar
?
.
isHidden
=
false
v
.
isHidden
=
false
tabBar
?
.
y
=
0
v
.
y
=
0
case
.
bottom
:
case
.
bottom
:
tabBar
?
.
isHidden
=
false
v
.
isHidden
=
false
tabBar
?
.
y
=
y
v
.
y
=
y
case
.
hidden
:
case
.
hidden
:
tabBar
?
.
isHidden
=
true
v
.
isHidden
=
true
}
}
}
}
}
}
...
@@ -411,13 +431,13 @@ extension PageMenuController {
...
@@ -411,13 +431,13 @@ extension PageMenuController {
- Parameter at index: An Int for the view controller position.
- Parameter at index: An Int for the view controller position.
*/
*/
fileprivate
func
removeViewController
(
at
index
:
Int
)
{
fileprivate
func
removeViewController
(
at
index
:
Int
)
{
let
v
c
=
viewControllers
[
index
]
let
v
=
viewControllers
[
index
]
guard
childViewControllers
.
contains
(
v
c
)
else
{
guard
childViewControllers
.
contains
(
v
)
else
{
return
return
}
}
removeViewController
(
viewController
:
v
c
)
removeViewController
(
viewController
:
v
)
}
}
/**
/**
...
@@ -450,12 +470,15 @@ extension PageMenuController {
...
@@ -450,12 +470,15 @@ extension PageMenuController {
return
return
}
}
removeViewControllers
()
prepareViewControllersForTransition
(
from
:
selectedIndex
,
to
:
i
)
selectedIndex
=
i
selectedIndex
=
i
v
.
select
(
at
:
i
)
v
.
select
(
at
:
i
)
removeViewControllers
()
//prepareTabBar()
prepareViewControllers
()
//layoutSubviews()
layoutSubviews
()
}
}
}
}
...
@@ -469,6 +492,7 @@ extension PageMenuController: UIScrollViewDelegate {
...
@@ -469,6 +492,7 @@ extension PageMenuController: UIScrollViewDelegate {
removeViewControllers
()
removeViewControllers
()
prepareViewControllers
()
prepareViewControllers
()
prepareTabBar
()
layoutSubviews
()
layoutSubviews
()
}
}
}
}
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