suzui11111的专栏

#import <UIKit/UIKit.h>

#import "GravityBallView.h"

@interface ViewController :UIViewController <GravityBallViewDelegate>

@property (nonatomic,strong) GravityBallView *gravityBallView;

@property (nonatomic,strong

@end

//

#import "ViewController.h"

@interfaceViewController ()

@property (nonatomic,strong

@property (nonatomic,strong

@property (nonatomic,strong

@end

@implementation ViewController

@synthesize gravityBallView =_gravityBallView;

@synthesize imageView =_imageView;

@synthesize button =_button;

@synthesize bounderView =_bounderView;

@synthesize

– (void)viewDidLoad

{

[superviewDidLoad];

_bounderView = [[UIViewalloc] init];

[_bounderView, -//是不是self自带的这个view是不能改大小的?原来的写法是直接self.view setFrame不管用。

colorWithRedblue:0.2alpha

addSubview:_bounderView];

CGRect gravityBallViewFrame = CGRectMake(0, 0, 40, 40);

_gravityBallView = [[GravityBallViewalloc] initWithFrame:gravityBallViewFrame];

_gravityBallView];

_gravityBallView.delegate =self;

_imageView = [[UIImageViewalloc] initWithFrame:gravityBallViewFrame];

imageNamed:@"billiard.png"];

[_gravityBallViewaddSubview:_imageView];

[_gravityBallViewstartUpdateAccelerometer];

alloc] initWithFrame:CGRectMake(10,

colorWithRedblue:0.8alpha

[self.viewaddSubview:_label];

alloc] initWithFrame:CGRectMake(220,

colorWithRedblue:0.2alpha

forState:UIControlStateNormal];

action:@selector(onButtonClicked:)forControlEvents:UIControlEventTouchUpInside];

[self.viewaddSubview:_button];

}

– (void)onButtonClicked:(UIButton*)button{

_gravityBallView.mManagerisAccelerometerActive] ==YES)

{

[_gravityBallViewstopUpdate];

forState:UIControlStateNormal];

_gravityBallView.mManagerisAccelerometerActive] !=YES) &&

([_gravityBallView.mManagerisAccelerometerAvailable] == YES))

{

[_gravityBallViewstartUpdateAccelerometer];

forState:UIControlStateNormal];

}

else

{

@"what’s happenning?\n");

}

}

– (void)didReceiveMemoryWarning

{

[superdidReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

– (void)viewWillDisappear:(BOOL)animated

{

[_gravityBallViewstopUpdate];

}

#pragma GravityBallViewDelegate

– (void)updateLabelWithX:(double)accelerometerX Y:(double)accelerometerY

{

不然你大概会一直好奇和不甘吧——家门前的那条小路,

suzui11111的专栏

相关文章:

你感兴趣的文章:

标签云: