私はあなたの指揮をとり、スクリーンキャストも行いました。 Was this what you had in mind?
アニメーションを無期限に繰り返すので、ビデオで簡単にキャプチャすることができますが、ボタンを押すだけで起動でき、反転表示までポップオーバーとその内容を表示できますもう一度隠される。
CALayerのマスクプロパティを使用してポップオーバーを非表示にし、スライドアニメーションで表示するため、UIViewのアニメーション化ではなく、Core Animationを使用しました。ここで
は、私が使用したコードは、(ビデオと同じ)である:
- (void)viewDidLoad
{
// Declaring the popover layer
CALayer *popover = [CALayer layer];
CGFloat popoverHeight = 64.0f;
CGFloat popoverWidth = 200.0f;
popover.frame = CGRectMake(50.0f, 100.0f, popoverWidth, popoverHeight);
popover.contents = (id) [UIImage imageNamed:@"popover.png"].CGImage;
// Declaring the mask layer
CALayer *maskLayer = [CALayer layer];
maskLayer.frame = CGRectMake(0, - popoverHeight, popoverWidth, popoverHeight);
maskLayer.backgroundColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f].CGColor;
// Setting the animation (animates the mask layer)
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
animation.byValue = [NSNumber numberWithFloat:popoverHeight];
animation.repeatCount = HUGE_VALF;
animation.duration = 2.0f;
[maskLayer addAnimation:animation forKey:@"position.y"];
//Assigning the animated maskLayer to the mask property of your popover
popover.mask = maskLayer;
[self.view.layer addSublayer:popover];
[super viewDidLoad];
}
は注:あなたは、あなたのプロジェクトにQuartzCoreフレームワークをインポートし、ヘッダファイルに次の行を記述する必要があります#import <QuartzCore/QuartzCore.h>
。
これはあなたのために働くか、これを設定するためのヘルプが必要かどうかを伝えます。
アニメーションを繰り返して表示した後に追加したままにするにはどうすればよいですか?ありがとう。 –