Files
react-native-svg/ios/Elements/RNSVGSvgView.m
Horcrux 6a0c47a898 refactor clipPath native code
refactor clipPath native code
add strokeMiterlimit prop support
2016-05-21 19:58:49 +08:00

68 lines
1.4 KiB
Objective-C

/**
* Copyright (c) 2015-present, Horcrux.
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RNSVGSvgView.h"
#import "RNSVGNode.h"
#import "RCTLog.h"
@implementation RNSVGSvgView
{
NSMutableDictionary *clipPaths;
}
- (void)invalidate
{
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
for (RNSVGNode *node in self.subviews) {
[node renderTo:context];
if (node.touchable && !self.touchable) {
self.touchable = YES;
}
}
}
- (void)reactSetInheritedBackgroundColor:(UIColor *)inheritedBackgroundColor
{
self.backgroundColor = inheritedBackgroundColor;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
return self.touchable ? [super hitTest:point withEvent:event] : nil;
}
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId
{
if (clipPaths == NULL) {
clipPaths = [[NSMutableDictionary alloc] init];
}
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathId];
}
- (void)removeClipPath:(NSString *)clipPathId
{
if (clipPaths != NULL) {
[clipPaths removeObjectForKey:clipPathId];
}
}
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId
{
return [[clipPaths valueForKey:clipPathId] pointerValue];
}
@end