首页 > 编程语言 > 详细

Swift-UIDynamic初见

时间:2015-08-04 00:29:01      阅读:291      评论:0      收藏:0      [点我收藏+]
 1 import UIKit
 2 
 3 class ViewController: UIViewController {
 4 
 5     @IBOutlet weak var dview: UIView!
 6     var dynamicAnimator = UIDynamicAnimator();
 7     override func viewDidLoad() {
 8         super.viewDidLoad()
 9         // Do any additional setup after loading the view, typically from a nib
10         dynamicAnimator = UIDynamicAnimator(referenceView: self.view);
11         // 創建并添加重力行為
12         let gravityBehavior = UIGravityBehavior(items: [self.dview]);
13         dynamicAnimator.addBehavior(gravityBehavior);
14         
15         // 創建并添加碰撞行為
16         let collisionBehavior = UICollisionBehavior(items: [self.dview]);
17         collisionBehavior.translatesReferenceBoundsIntoBoundary = true;
18         dynamicAnimator.addBehavior(collisionBehavior);
19     }
20 
21     override func didReceiveMemoryWarning() {
22         super.didReceiveMemoryWarning()
23         // Dispose of any resources that can be recreated.
24     }
25     override func viewDidAppear(animated: Bool) {
26         super.viewDidAppear(animated);
27         
28     }
29 
30 }

技术分享

参考资料:

抄自《Swift与Cocoa框架开发》

 

 

Swift-UIDynamic初见

原文:http://www.cnblogs.com/yanshinian/p/4700607.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!