add dashoffset support

This commit is contained in:
Horcrux
2016-04-23 15:21:07 +08:00
parent 05faac3cf1
commit b144bd23fc
9 changed files with 60 additions and 11 deletions
+1 -2
View File
@@ -59,9 +59,8 @@
CGContextSetLineJoin(context, self.strokeLinejoin);
RNSVGCGFloatArray dash = self.strokeDash;
// TODO: render as web svgs do
if (dash.count) {
CGContextSetLineDash(context, 0, dash.array, dash.count);
CGContextSetLineDash(context, self.strokeDashoffset, dash.array, dash.count);
}
if (!fillColor) {
+1
View File
@@ -22,5 +22,6 @@
@property (nonatomic, assign) CGLineCap strokeLinecap;
@property (nonatomic, assign) CGLineJoin strokeLinejoin;
@property (nonatomic, assign) RNSVGCGFloatArray strokeDash;
@property (nonatomic, assign) CGFloat strokeDashoffset;
@end
+6
View File
@@ -52,6 +52,12 @@
_strokeDash = strokeDash;
}
- (void)setStrokeDashoffset:(CGFloat)strokeDashoffset
{
[self invalidate];
_strokeDashoffset = strokeDashoffset;
}
- (void)dealloc
{
if (_strokeDash.array) {
+2 -1
View File
@@ -84,8 +84,9 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
CGContextSetLineCap(context, self.strokeLinecap);
CGContextSetLineJoin(context, self.strokeLinejoin);
RNSVGCGFloatArray dash = self.strokeDash;
if (dash.count) {
CGContextSetLineDash(context, 0, dash.array, dash.count);
CGContextSetLineDash(context, self.strokeDashoffset, dash.array, dash.count);
}
if (![self.stroke applyStrokeColor:context]) {
+2 -1
View File
@@ -26,8 +26,9 @@ RCT_EXPORT_VIEW_PROPERTY(stroke, RNSVGBrush)
RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(strokeLinecap, CGLineCap)
RCT_EXPORT_VIEW_PROPERTY(strokeLinejoin, CGLineJoin)
RCT_EXPORT_VIEW_PROPERTY(strokeDash, RNSVGCGFloatArray)
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
RCT_EXPORT_VIEW_PROPERTY(strokeDash, RNSVGCGFloatArray)
RCT_EXPORT_VIEW_PROPERTY(strokeDashoffset, CGFloat)
@end