1, Cashapelayer introduction
- 1, Cashapelayer inherit to Calayer, can use all the property values of Calayer
- 2. Cashapelayer needs to be used in conjunction with Bezier curves to make sense
- 3, using Cashapelayer and Bezier curve can be implemented in the view of the DrawRect method to draw some of the desired graphics
- 4, Cashapelayer belongs to the coreanimation frame, its animation rendering directly to the mobile phone GPU, compared to the view of the DrawRect method using CPU rendering, it is very efficient, can greatly optimize memory usage
Effect:2. The relationship between Bezier curve and Cashapelayer
- 1, Cashapelayer has shape this word, as the name implies, it needs a shape to take effect
- 2. Bezier curves can create vector-based paths
- 3, Bezier curve to Cashapelayer provide a path, cashapelayer in the provided path to render, the path will be closed loop, so the path is drawn out shape
- 4, the Bezier curve for Cashapelayer as path, whose path is a closed-loop, end-to-end curve, even if the Bezier curve is not a closed-loop curve
The first order Bezier curve quadratic Bezier curve Sanche Besel curve Shirer Besel curve The five-order Bezier curve then the relationship between the Bezier curve and the cashapelayer is directly represented by the code:3, Strokestart and strokeend animation
- 1, set the fillcolor of Shapelayer to transparent background
- 2. Set the value of the line width (linewidth)
- 3. Set the color of the line
- 4, set the Strokestart value to 0, and then let the Strokeend value change trigger the implicit animation
Then in order to achieve the effect of the circular progress bar: The effect is: The above Strokestart also set, but note: Strokestart must be less than strokeend, otherwise will not draw the case.
Use of Cashapelayer in IOS