[iOS]UIInterpolatingMotionEffect重力视觉差_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > [iOS]UIInterpolatingMotionEffect重力视觉差

[iOS]UIInterpolatingMotionEffect重力视觉差

 2017/6/24 5:31:55  EverNight  程序员俱乐部  我要评论(0)
  • 摘要:-(void)viewDidLoad{[superviewDidLoad];//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.self.view.backgroundColor=[UIColorgrayColor];UIView*view=[[UIViewalloc]initWithFrame:self.view.bounds];view.backgroundColor=[UIColorblueColor];view
  • 标签:ERP iOS
- (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];
}

初始效果图

倾斜屏幕后效果图

发表评论
用户名: 匿名