Great blogpost! I tried translating it into objective C, but seem to run into some issues:
in AppDidLaunch
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
imageView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:imageView];
[self.window bringSubviewToFront:imageView];
self.mask = [CALayer layer];
self.mask.contents = (__bridge id)([UIImage imageNamed:@"venue_pin_newblue"].CGImage);
self.mask.bounds = CGRectMake(0, 0, 100, 100);
self.mask.anchorPoint = CGPointMake(0.5, 0.5);
self.mask.position = CGPointMake(imageView.frame.size.width/2, imageView.frame.size.height/2);
self.imageView.layer.mask = _mask;
self.imageView = imageView;
[self animateMaks];
-(void) animateMask {
NSLog(@"start animation");
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimation animationWithKeyPath:@"bounds"];
keyFrameAnimation.delegate = self;
keyFrameAnimation.duration = 1;
keyFrameAnimation.beginTime = CACurrentMediaTime() + 1; //add delay of 1 second
NSValue *initialBounds = [NSValue valueWithCGRect:_mask.bounds];
NSValue *secondBounds = [NSValue valueWithCGRect:CGRectMake(0, 0, 90, 90)];
NSValue *finalBounds = [NSValue valueWithCGRect:CGRectMake(0, 0, 1500, 1500)];
NSArray *valuesArray = @[initialBounds, secondBounds, finalBounds];
keyFrameAnimation.values = valuesArray;
CAMediaTimingFunction *t1 = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CAMediaTimingFunction *t2 = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
NSArray *timingFunctions = @[t1, t2];
keyFrameAnimation.timingFunctions = timingFunctions;
NSArray *keyTimes = @[@0, @0.3, @1];
keyFrameAnimation.keyTimes = keyTimes;
[self.mask addAnimation:keyFrameAnimation forKey:@"bounds"];
}
any suggestions of what might be causing the problem? Thanks!
Great blogpost! I tried translating it into objective C, but seem to run into some issues:
in AppDidLaunch
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
imageView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:imageView];
[self.window bringSubviewToFront:imageView];
[self animateMaks];
-(void) animateMask {
NSLog(@"start animation");
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimation animationWithKeyPath:@"bounds"];
keyFrameAnimation.delegate = self;
keyFrameAnimation.duration = 1;
keyFrameAnimation.beginTime = CACurrentMediaTime() + 1; //add delay of 1 second
}
any suggestions of what might be causing the problem? Thanks!