\"QiuQianViewController.h\"#import
\"ResultViewController.h\"@interface
QiuQianViewController (){
NSMutableArray
*_xiaoQianArray;//12
NSArray *_jieQianArray;//
NSTimer *timer; NSTimer *timerone; NSTimer
*_fiveQianHeTimer;// int count;}
@property (weak, nonatomic) IBOutlet UILabel *labelone;@property (weak, nonatomic) IBOutlet UIButton *backButton;@property (weak, nonatomic)
IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIButton *startButton;@property (weak, nonatomic) IBOutlet UIImageView *daQianHe;@property (strong, nonatomic) IBOutletCollection(UIImageView) NSArray *fiveQianHeArray;@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage;@end
@implementation
QiuQianViewController
- (void)viewDidLoad { [super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// NSArray *imageArray = @[[UIImage
imageNamed:@\"qiuqian0.png\"],[UIImage
imageNamed:@\"qiuqian1.png\"],[UIImage
imageNamed:@\"qiuqian2.png\"]]; //
_daQianHe.animationDuration = 0.5;
_daQianHe.animationImages = imageArray;
_daQianHe.animationRepeatCount = 0;
_xiaoQianArray =
@[].mutableCopy;//
//12
for (int i = 0; i<12; i++) {
UIImageView *xiaoQianHe = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@\"qiuqian0.png\"]]; xiaoQianHe.tag = i*30; xiaoQianHe.center = CGPointMake(_daQianHe.center.x + 150*cos(xiaoQianHe.tag/
180.0*M_PI), _daQianHe.center.y + 100* sin(xiaoQianHe.tag/180.0*M_PI));
xiaoQianHe.bounds = CGRectMake(0, 0, 30, 45); xiaoQianHe.hidden = YES;
[self.view
addSubview:xiaoQianHe]; [_xiaoQianArray addObject:xiaoQianHe]; }
//
_jieQianArray = @[@\"\",@\"\",@\"\",];
// for (UIImageView
*fiveQianHe in
_fiveQianHeArray) {
fiveQianHe.animationDuration = 0.5;
fiveQianHe.animationImages = imageArray;
fiveQianHe.animationRepeatCount = 0; }}
#pragma mark -
- (IBAction)gotoBack:(UIButton *)sender {
[self.navigationController popViewControllerAnimated:YES];}
#pragma mark - - (IBAction)startQiuQian:(UIButton *)sender {
_labelone.hidden = YES;//
_startButton.hidden = YES;//
//
[_daQianHe startAnimating];
//12
[self
performSelector:@selector(qianHeAnimation) withObject:nil afterDelay:2];}
#pragma mark -
- (void)qianHeAnimation {
//
[_daQianHe stopAnimating];
//12 for (UIImageView
*xiaoQianHe in _xiaoQianArray) {
xiaoQianHe.hidden = NO; }
// 12 timer = [NSTimer
scheduledTimerWithTimeInterval:0.1 target:self
selector:@selector(smallQianhHeAnimation) userInfo:nil repeats:YES];
//label timerone = [NSTimer
scheduledTimerWithTimeInterval:0.5 target:self
selector:@selector(jieQianAnimation) userInfo:nil repeats:YES];
//label
_label.hidden = NO;
//
_fiveQianHeTimer = [NSTimer scheduledTimerWithTimeInterval:
1 target:self
selector:@selector(fiveQianHeAnimation) userInfo:nil repeats:YES];}
#pragma mark - 12
- (void)smallQianhHeAnimation { static int angle = 0; angle += 5;
NSLog(@\"123546546\");//
for (UIImageView
*xiaoQianHe in _xiaoQianArray) {
xiaoQianHe.center = CGPointMake(_daQianHe.center.x + 150*cos((xiaoQianHe.tag+angle)/180.0*M_PI), _daQianHe.center.y +
100*sin((xiaoQianHe.tag+angle)/
180.0*M_PI));
//yy
if (xiaoQianHe.center.y < _daQianHe.center.y) {
// [self.view
sendSubviewToBack:xiaoQianHe]; //
[self.view
sendSubviewToBack:_backgroundImage];
}else {
// yy
[self.view
bringSubviewToFront:xiaoQianHe];
} }}
#pragma mark - label- (void)jieQianAnimation {
//
static int index = 0;
// _jieQianLabel.text = _jieQianArray[index%3];
_label.text = [_jieQianArray
objectAtIndex:index%3]; index ++;}
#pragma mark - - (void)fiveQianHeAnimation { if (count > 4) {
[_fiveQianHeTimer invalidate];
_fiveQianHeTimer = nil; ResultViewController *resultVC =
[[ResultViewController alloc] init];
[self.navigationController pushViewController:resultVC animated:YES]; }else {
UIImageView *fiveQianHe = _fiveQianHeArray[count]; [fiveQianHe startAnimating]; }
count ++;}
//
- (void)viewWillDisappear:(BOOL)animated{
for (UIImageView *fiveQianHe in
_fiveQianHeArray) { [fiveQianHe stopAnimating]; }
for (UIImageView
*xiaoQianHe in _xiaoQianArray) {
xiaoQianHe.hidden = YES;
}
_label.hidden = YES; _labelone.hidden = NO; _startButton.hidden = NO; [timer invalidate]; timer = nil;
[_fiveQianHeTimer invalidate];
_fiveQianHeTimer = nil; [timerone invalidate]; timerone = nil; count = 0;
[QiuQianViewController
cancelPreviousPerformRequestsWithTarget:self
selector:@selector(qianHeAnimation) object:nil];}
因篇幅问题不能全部显示,请点此查看更多更全内容