統計情報(30日間)


最新情報をツイート


人気の投稿

Parallxing効果の公式サンプル、でた

このエントリーをはてなブックマークに追加

やっとでた?



デモは3つ

ロック画面でお馴染みのやつ

UIInterplatingMotionEffectというクラスを使っていてたったこれだけ。
UIInterpolatingMotionEffect *xAxis = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
        xAxis.minimumRelativeValue = @(25.0);
        xAxis.maximumRelativeValue = @(-25.0);
        
        UIInterpolatingMotionEffect *yAxis = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
        yAxis.minimumRelativeValue = @(32.0);
        yAxis.maximumRelativeValue = @(-32.0);
        
        self.backgroundMotionEffect = [[UIMotionEffectGroup alloc] init];
        self.backgroundMotionEffect.motionEffects = @[xAxis, yAxis];
        
        [self.backgroundView addMotionEffect:self.backgroundMotionEffect];
ほお。


2番めは手前のウィンドウがBlurな場合。このBlurなビューはあらかじめ用意された画像。磨りガラス状の半透明なビューにも背景のParallxing効果がちゃんと反映されている。

最後のやつは手前の木と背景が独立して動いて擬似的な立体感がある。


UIInterpolatingMotionEffectのリファレンス


Leave a Reply