我正在学习本教程:http://ios-blog.co.uk/tutorials/ios-7-how-to-use-uigravitybehavior/我已经设法使其工作得很好(感谢有用的视频)。但是我现在想让*图像从随机位置掉落。我将如何实现这一目标?
这是.h文件:
@property (nonatomic, weak) IBOutlet UIImageView *image;
@property (nonatomic) UIDynamicAnimator *animator;
-(IBAction)Start;
这是.m文件:
@synthesize animator = _animator;
-(IBAction)Start {
_animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[self.image]];
[_animator addBehavior:gravityBehavior];
}