zoukankan      html  css  js  c++  java
  • [iOS]UIInterpolatingMotionEffect重力视觉差

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        
        self.view.backgroundColor = [UIColor grayColor];
        
        UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
        view.backgroundColor = [UIColor blueColor];
        view.layer.borderColor = [[UIColor greenColor] CGColor];
        view.layer.borderWidth = 5.0;
        [self.view addSubview:view];
        
        // 创建偏移
        UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc]
                                                initWithKeyPath:@"center.x"
                                                type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
        UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc]
                                                initWithKeyPath:@"center.y"
                                                type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
        
        // 设置最大值和最小值
        effectX.maximumRelativeValue = @(100);
        effectX.minimumRelativeValue = @(-100);
        effectY.maximumRelativeValue = @(100);
        effectY.minimumRelativeValue = @(-100);
        
        [view addMotionEffect:effectX];
        [view addMotionEffect:effectY];
    }

    初始效果图

    倾斜屏幕后效果图

  • 相关阅读:
    企信通自动登录问题解决
    BPM保存提交审核时后台校验数据
    初始化BPM
    BPM删除事件,删除表单
    flowportal数据字典
    百度网盘
    HPC 有哪些应用层?
    公众号改名字了:子郁定投上海
    一些网站和他们的关键词介绍
    如何找到女朋友
  • 原文地址:https://www.cnblogs.com/EverNight/p/7070406.html
Copyright © 2011-2022 走看看