NSScreencast Episode #40 Shine Effect
タイトルバーにShineエフェクトをつける
- shine logo on titlebar
- logo - black
- highlighted version - white
- mask - black
- titleView = logo view (UIImageView)
- CALayer
- CALayer *shineLayer = [CALayer layer];
- shineLayer.contents = (id)[shineImage CGImage];
- mask
- mask.backgroundColor = [[UIColor clearColor] CGColor];
- mask.contentsGravity = kCAGravityCenter;
- mask.frame = CGRectMake(-width, 0, width * 1.25, height);
- Animating the mask
- CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position.x"];
- anim
- .byValue
- .repeatCount = HUGE_VALF;
- .duration
- .timingFunction
- = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- [self.layer addSublayer:shineLayer];
- [mask addAnimation:anim forKey:@"shine"];