/
README.txt
71 lines (55 loc) · 3.77 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
YRKSpinningProgressIndicatorLayer and SPILDemo.app
Written by:
Kelan Champagne
http://yeahrightkeller.com
Please feel free to send me questions or comments.
History:
v1.0 2008-07-08 KJC
v1.1 2009-02-14 KJC
Overview:
YRKSpinningProgressIndicatorLayer is a clone of the NSProgressIndicator (spinning-style) that can be set to an arbitrary size and color, and used with CoreAnimation layers.
Features:
* implemented as a subclass of CALayer
* can be used with and overlaid on other CALayers
* can be set to arbitrary size and color
* can even be changed while animating
* upon starting animation, each "fin" appears only when it is first drawn
* when animating, each fin fades from opaque to transparent
* as they fade, you can see through the fins to the background
* when stopped, no new fins are drawn, and the existing fins fade to transparent
Code Architecture:
* Implemented as a subclass of CALayer.
* Each fin is a sub-layer made of a generic CALayer and drawn by setting the bounds, corner radius, and background color.
* Animation is done with an NSTimer.
Notes/Limitations:
* If resized really fast, some fins will not be drawn.
* When drawn a large size (i.e. full-screen), the animation can take up a pretty good chunk of CPU. But, at smaller sizes, it's not bad. The good news is that since it's Leopard-only, it won't be running on anything slower than 800mhz/512MB ram. I tested it on my PPC revA Mac Mini that is 1.25Ghz/512MB (and weak graphics), and it ran OK at everything except full-screen. The QC composition in the background of the demo app was a much bigger culprit though, and with the solid background, it is ok. So, hopefully the performance is acceptable. If not, I have an idea for caching all the fin images, instead of having CoreAnimation do all the drawing on the fly. But, the way it is now makes for really clean code, so I left it like that for now.
* For some reason, the Quartz Composer background (with the clouds) of the SPILDemo app doesn't animate when built in Release mode.
Code Conventions:
* Instance variables are prefixed with an underscore (i.e. "_").
* "Private" methods are declared in a Class Continuation (i.e. name-less category) at the top of the .m file.
License:
(The BSD License)
Copyright (c) 2009, Kelan Champagne (http://yeahrightkeller.com)
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 the <organization> 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 Kelan Champagne ''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 Kelan Champagne 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.
Also, I'd appreciate it if you would let me know if you find this code useful.