Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
PNChart
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Emma Makinson
2015-12-18 16:24:20 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a50bc0ebd5012b3552726e27149173336f39b90a
a50bc0eb
1 parent
85d88517
Add configuration to other animations in bar chart
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
42 deletions
PNChart/PNBar.m
PNChart/PNBarChart.m
PNChart/PNBar.m
View file @
a50bc0e
...
...
@@ -225,29 +225,24 @@
frame
.
origin
.
x
=
(
self
.
bounds
.
size
.
width
-
size
.
width
)
/
2
.
0
;
frame
.
size
=
size
;
self
.
textLayer
.
frame
=
frame
;
CABasicAnimation
*
rotationAnimation
;
rotationAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"transform.rotation.z"
];
rotationAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
M_PI
];
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
rotationAnimation
.
duration
=
0
.
1
;
rotationAnimation
.
repeatCount
=
0
;
//你可以设置到最大的整数值
rotationAnimation
.
cumulative
=
NO
;
rotationAnimation
.
removedOnCompletion
=
NO
;
rotationAnimation
.
fillMode
=
kCAFillModeForwards
;
[
self
.
textLayer
addAnimation
:
rotationAnimation
forKey
:
@"Rotation"
];
[
self
addRotationAnimationIfNeeded
];
}
}
-
(
CABasicAnimation
*
)
fadeAnimation
{
CABasicAnimation
*
fadeAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"opacity"
];
fadeAnimation
.
fromValue
=
[
NSNumber
numberWithFloat
:
0
.
0
];
fadeAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
1
.
0
];
fadeAnimation
.
duration
=
2
.
0
;
return
fadeAnimation
;
if
(
self
.
displayAnimated
)
{
CABasicAnimation
*
fadeAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"opacity"
];
fadeAnimation
.
fromValue
=
[
NSNumber
numberWithFloat
:
0
.
0
];
fadeAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
1
.
0
];
fadeAnimation
.
duration
=
2
.
0
;
return
fadeAnimation
;
}
else
{
return
nil
;
}
}
-
(
void
)
addAnimationIfNeededWithProgressLine
:
(
UIBezierPath
*
)
progressline
...
...
@@ -277,4 +272,20 @@
}
}
-
(
void
)
addRotationAnimationIfNeeded
{
if
(
self
.
displayAnimated
)
{
CABasicAnimation
*
rotationAnimation
;
rotationAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"transform.rotation.z"
];
rotationAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
M_PI
];
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
rotationAnimation
.
duration
=
0
.
1
;
rotationAnimation
.
repeatCount
=
0
;
//你可以设置到最大的整数值
rotationAnimation
.
cumulative
=
NO
;
rotationAnimation
.
removedOnCompletion
=
NO
;
rotationAnimation
.
fillMode
=
kCAFillModeForwards
;
[
self
.
textLayer
addAnimation
:
rotationAnimation
forKey
:
@"Rotation"
];
}
}
@end
...
...
PNChart/PNBarChart.m
View file @
a50bc0e
...
...
@@ -325,14 +325,6 @@
[
progressline
setLineCapStyle
:
kCGLineCapSquare
];
_chartBottomLine
.
path
=
progressline
.
CGPath
;
_chartBottomLine
.
strokeColor
=
[
_chartBorderColor
CGColor
];;
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathAnimation
.
duration
=
0
.
5
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
@0.0f
;
pathAnimation
.
toValue
=
@1.0f
;
[
_chartBottomLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
_chartBottomLine
.
strokeEnd
=
1
.
0
;
[
self
.
layer
addSublayer
:
_chartBottomLine
];
...
...
@@ -354,16 +346,9 @@
[
progressLeftline
setLineCapStyle
:
kCGLineCapSquare
];
_chartLeftLine
.
path
=
progressLeftline
.
CGPath
;
_chartLeftLine
.
strokeColor
=
[
_chartBorderColor
CGColor
];
CABasicAnimation
*
pathLeftAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathLeftAnimation
.
duration
=
0
.
5
;
pathLeftAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathLeftAnimation
.
fromValue
=
@0.0f
;
pathLeftAnimation
.
toValue
=
@1.0f
;
[
_chartLeftLine
addAnimation
:
pathLeftAnimation
forKey
:
@"strokeEndAnimation"
];
_chartLeftLine
.
strokeEnd
=
1
.
0
;
[
self
addBorderAnimationIfNeeded
];
[
self
.
layer
addSublayer
:
_chartLeftLine
];
}
...
...
@@ -385,14 +370,8 @@
_chartLevelLine
.
path
=
progressline
.
CGPath
;
_chartLevelLine
.
strokeColor
=
PNLightGrey
.
CGColor
;
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathAnimation
.
duration
=
0
.
5
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
@0.0f
;
pathAnimation
.
toValue
=
@1.0f
;
[
_chartLevelLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
[
self
addSeparatorAnimationIfNeeded
];
_chartLevelLine
.
strokeEnd
=
1
.
0
;
[
self
.
layer
addSublayer
:
_chartLevelLine
];
...
...
@@ -404,6 +383,37 @@
}
}
-
(
void
)
addBorderAnimationIfNeeded
{
if
(
self
.
displayAnimated
)
{
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathAnimation
.
duration
=
0
.
5
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
@0.0f
;
pathAnimation
.
toValue
=
@1.0f
;
[
_chartBottomLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
CABasicAnimation
*
pathLeftAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathLeftAnimation
.
duration
=
0
.
5
;
pathLeftAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathLeftAnimation
.
fromValue
=
@0.0f
;
pathLeftAnimation
.
toValue
=
@1.0f
;
[
_chartLeftLine
addAnimation
:
pathLeftAnimation
forKey
:
@"strokeEndAnimation"
];
}
}
-
(
void
)
addSeparatorAnimationIfNeeded
{
if
(
self
.
displayAnimated
)
{
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathAnimation
.
duration
=
0
.
5
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
@0.0f
;
pathAnimation
.
toValue
=
@1.0f
;
[
_chartLevelLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
}
}
-
(
void
)
viewCleanupForCollection
:
(
NSMutableArray
*
)
array
{
if
(
array
.
count
)
{
...
...
Please
register
or
login
to post a comment