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];
    }

    初始效果图

    倾斜屏幕后效果图

  • 相关阅读:
    20161203
    20161201
    20161128课堂笔记
    数组排序 (选择排序、冒泡排序、插入排序、希尔排序)
    编一个多用户登陆程序
    20161115课堂笔记
    20161114课堂笔记
    20161111课堂笔记
    面试常见问题
    java 基础第一周
  • 原文地址:https://www.cnblogs.com/EverNight/p/7070406.html
Copyright © 2011-2022 走看看