CALayers
フレームワークでpresentを利用しQuartzCore
ます。
背景が黒で角が丸い新しいレイヤーを作成します。次に、画像をサブレイヤーとして追加します。
CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor blueColor].CGColor;
sublayer.shadowOffset = CGSizeMake(0, 3);
sublayer.shadowRadius = 5.0;
sublayer.shadowColor = [UIColor blackColor].CGColor;
sublayer.shadowOpacity = 0.8;
sublayer.frame = CGRectMake(30, 30, 128, 192);
sublayer.borderColor = [UIColor blackColor].CGColor;
sublayer.borderWidth = 2.0;
sublayer.cornerRadius = 10.0;
[self.view.layer addSublayer:sublayer];
CALayer *imageLayer = [CALayer layer];
imageLayer.frame = sublayer.bounds;
imageLayer.cornerRadius = 10.0;
imageLayer.contents = (id) [UIImage imageNamed:@"myImage.png"].CGImage;
imageLayer.masksToBounds = YES;
[sublayer addSublayer:imageLayer];
輝く効果を提供するには、このコードを利用してください。
CABasicAnimation* animation1 = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation1 setDuration:1.0];
[animation1 setRepeatCount:INT_MAX];
[animation1 setFromValue:[NSNumber numberWithFloat:0.0]];
[animation1 setToValue:[NSNumber numberWithFloat:1.0]];
[subLayer addAnimation:animation1 forKey:nil];