IOS基础之愤怒的小方块
#import "ViewController.h"
typedef struct YHValue YHValue;
struct YHValue {
CGFloat startValue;
CGFloat endValue;
};
static inline YHValue
YHValueMake(CGFloat startValue,CGFloat endValue){
YHValue value;
value.startValue = startValue;
value.endValue = endValue;
return value;
}
@interface ViewController () <UICollisionBehaviorDelegate>
@property(nonatomic,strong)UIDynamicAnimator *animator;
@property(nonatomic,weak)UIView *pigView;
@property(nonatomic,strong)UIGravityBehavior *gravity;
- (IBAction)refresh:(id)sender;
@end
@implementation ViewController
- (IBAction)refresh:(id)sender {
[self setupUI];
}
- (UIDynamicAnimator *)animator{
if(!_animator){
_animator = [[UIDynamicAnimator alloc] initWithReferen