zoukankan      html  css  js  c++  java
  • iOS 7 动画UIDynamicAnimator

    - (void)viewDidLoad
    {
        [super viewDidLoad]; 
        [self initUI];
        [self performSelector:@selector(startGravity:) withObject:Nil afterDelay:1];// Do any additional setup after loading the view, typically from a nib.
    }
    
    // 开始重力行为
    - (IBAction)startGravity:(id)sender
    {
     //  设为全局才会有效,不知什么原因 animator
    = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];//动画方法都根据这个调用 UIGravityBehavior* gravityBeahvior = [[UIGravityBehavior alloc] initWithItems:@[HUDView]]; [animator addBehavior:gravityBeahvior]; UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:HUDView attachedToAnchor:CGPointMake(100, 0)]; [attachmentBehavior setLength:200]; [attachmentBehavior setDamping:0.1]; [attachmentBehavior setFrequency:5]; [animator addBehavior:attachmentBehavior]; } -(void)initUI{ HUDView=[[UIView alloc]initWithFrame:(CGRectMake(0, 0, 100, 100))]; HUDView.backgroundColor=[UIColor orangeColor]; HUDView.backgroundColor=[UIColor redColor]; HUDView.center = CGPointMake(100, 100); HUDView.layer.cornerRadius=50; [self.view addSubview:HUDView]; }
  • 相关阅读:
    jQuery之五:CheckBox控制
    WinServer2003 设置之:xp风格
    ASP.net: cookie
    ASP.NET之:URL重写(转载)
    jQuery 之二:Ajax加载Json数据
    jQuery 之一:对象插件
    Asp.net:Form
    jQuery之四:Table过滤
    jQuery之三:Tab控制
    Opera 9.01 Build 8543
  • 原文地址:https://www.cnblogs.com/zhangsongbai/p/3488416.html
Copyright © 2011-2022 走看看