mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			101 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			101 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Objective-C
		
	
//
 | 
						|
//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | 
						|
//
 | 
						|
 | 
						|
#import <UIKit/UIKit.h>
 | 
						|
#import "OWSBezierPathView.h"
 | 
						|
 | 
						|
NS_ASSUME_NONNULL_BEGIN
 | 
						|
 | 
						|
#pragma mark -
 | 
						|
 | 
						|
@implementation OWSBezierPathView
 | 
						|
 | 
						|
- (id)init
 | 
						|
{
 | 
						|
    self = [super init];
 | 
						|
    if (self) {
 | 
						|
        [self initCommon];
 | 
						|
    }
 | 
						|
 | 
						|
    return self;
 | 
						|
}
 | 
						|
 | 
						|
- (id)initWithFrame:(CGRect)frame
 | 
						|
{
 | 
						|
    self = [super initWithFrame:frame];
 | 
						|
    if (self) {
 | 
						|
        [self initCommon];
 | 
						|
    }
 | 
						|
    return self;
 | 
						|
}
 | 
						|
 | 
						|
- (void)initCommon
 | 
						|
{
 | 
						|
    self.opaque = NO;
 | 
						|
    self.userInteractionEnabled = NO;
 | 
						|
}
 | 
						|
 | 
						|
- (void)setFrame:(CGRect)frame
 | 
						|
{
 | 
						|
    BOOL didChangeSize = !CGSizeEqualToSize(frame.size, self.frame.size);
 | 
						|
 | 
						|
    [super setFrame:frame];
 | 
						|
 | 
						|
    if (didChangeSize) {
 | 
						|
        [self updateLayers];
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
- (void)setBounds:(CGRect)bounds
 | 
						|
{
 | 
						|
    BOOL didChangeSize = !CGSizeEqualToSize(bounds.size, self.bounds.size);
 | 
						|
 | 
						|
    [super setBounds:bounds];
 | 
						|
 | 
						|
    if (didChangeSize) {
 | 
						|
        [self updateLayers];
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
- (void)setConfigureShapeLayerBlock:(ConfigureShapeLayerBlock)configureShapeLayerBlock
 | 
						|
{
 | 
						|
    [self setConfigureShapeLayerBlocks:@[ configureShapeLayerBlock ]];
 | 
						|
}
 | 
						|
 | 
						|
- (void)setConfigureShapeLayerBlocks:(NSArray<ConfigureShapeLayerBlock> *)configureShapeLayerBlocks
 | 
						|
{
 | 
						|
    _configureShapeLayerBlocks = configureShapeLayerBlocks;
 | 
						|
 | 
						|
    [self updateLayers];
 | 
						|
}
 | 
						|
 | 
						|
- (void)updateLayers
 | 
						|
{
 | 
						|
    if (self.bounds.size.width <= 0.f || self.bounds.size.height <= 0.f) {
 | 
						|
        return;
 | 
						|
    }
 | 
						|
 | 
						|
    for (CALayer *layer in self.layer.sublayers) {
 | 
						|
        [layer removeFromSuperlayer];
 | 
						|
    }
 | 
						|
 | 
						|
    // Prevent the shape layer from animating changes.
 | 
						|
    [CATransaction begin];
 | 
						|
    [CATransaction setDisableActions:YES];
 | 
						|
 | 
						|
    for (ConfigureShapeLayerBlock configureShapeLayerBlock in self.configureShapeLayerBlocks) {
 | 
						|
        CAShapeLayer *shapeLayer = [CAShapeLayer new];
 | 
						|
        configureShapeLayerBlock(shapeLayer, self.bounds);
 | 
						|
        [self.layer addSublayer:shapeLayer];
 | 
						|
    }
 | 
						|
 | 
						|
    [CATransaction commit];
 | 
						|
 | 
						|
    [self setNeedsDisplay];
 | 
						|
}
 | 
						|
 | 
						|
@end
 | 
						|
 | 
						|
NS_ASSUME_NONNULL_END
 |