Skip to content

Commit

Permalink
Pattern layer display fix
Browse files Browse the repository at this point in the history
  • Loading branch information
djphoenix committed May 14, 2015
1 parent 21d0487 commit cb9a313
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions pxSVG/pxSVGRenderPath.m
Expand Up @@ -35,8 +35,8 @@ @interface pxSVGRenderPath ()
@end

@interface pxSVGPatternLayer : CALayer
@property CALayer *patternLayer;
@property CATransform3D patternTransform;
@property (nonatomic) CALayer *patternLayer;
@property (nonatomic) CATransform3D patternTransform;
@end

@implementation pxSVGPatternLayer
Expand All @@ -49,11 +49,37 @@ + (instancetype)layer
- (instancetype)init
{
self = [super init];
self.delegate = self;
[self setNeedsDisplayOnBoundsChange:YES];
[self setNeedsDisplay];
return self;
}

- (void)dealloc
{
self.patternLayer = nil;
}

- (void)setPatternLayer:(CALayer *)patternLayer
{
_patternLayer = patternLayer;
[self setNeedsDisplay];
}

- (void)setPatternTransform:(CATransform3D)patternTransform
{
_patternTransform = patternTransform;
[self setNeedsDisplay];
}

- (void)setNeedsDisplay
{
if ([NSThread isMainThread]) return [super setNeedsDisplay];
__weak id weakself = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
if (weakself) [weakself setNeedsDisplay];
}];
}

- (void)drawInContext:(CGContextRef)ctx
{
CGRect r = CGContextGetClipBoundingBox(ctx);
Expand Down

0 comments on commit cb9a313

Please sign in to comment.