dimanche 26 avril 2015

Unit Testing State of Mask in CALayer

Trying to conduct a unit test to see on initialization i have set a mask of a layer, and even though i set it and check the value after it's set in the debugger, when i attempt to assert that it is not nil in the Unit Test it says nil...What gives?

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self)
    {
        [self setupEqualizerViewLayerMask];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setupEqualizerViewLayerMask];
    }
    return self;
}

- (void)setupEqualizerViewLayerMask
{
    // Create a mask layer and the frame to determine what will be visible in the view.
    _maskLayer = [[CAShapeLayer alloc] init];
    CGRect maskRect = CGRectMake(0, 0, _equalizerView.bounds.size.width, 0);

    // Create a path with the rectangle in it.
    CGPathRef path = CGPathCreateWithRect(maskRect, NULL);

    // Set the path to the mask layer.
    _maskLayer.path = path;

    // Release the path since it's not covered by ARC.
    CGPathRelease(path);

    // Set the mask of the view.
    [self.equalizerView.layer setMask:_maskLayer];
}

Aucun commentaire:

Enregistrer un commentaire