//
// ViewController.m
// test1222
//
// Created by zhangjian on 16/12/22.
// Copyright © 2016年 zhangjian. All rights
reserved.
//
#import "ViewController.h"
@interface ViewController ()
{
BOOL
animating;
UIView
*bgView;
UIView
*bg1;
UIImageView
*bgImageView1;
UIImageView
*bgImageView2;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
bgView =
[[UIView alloc]initWithFrame:CGRectMake((320-255)/2, 200, 255,
126)];
[self.view
addSubview:bgView];
UIImageView
*bgImageView = [[UIImageView alloc]
initWithFrame:bgView.frame];
bgImageView.image = [UIImage imageNamed:@"d.png"];
[self.view
addSubview:bgImageView];
bg1 =
[[UIView alloc]initWithFrame:CGRectMake(20, (126-61)/2, 61,
61)];
[bgImageView
addSubview:bg1];
bgImageView1
= [[UIImageView alloc] initWithFrame:CGRectMake(20, (126-61)/2, 61,
61)];
bgImageView1.image = [UIImage imageNamed:@"c1.png"];
[bgImageView
addSubview:bgImageView1];
bgImageView2
= [[UIImageView alloc] initWithFrame:CGRectMake(20, (126-61)/2, 61,
61)];
bgImageView2.image = [UIImage imageNamed:@"c.png"];
[bgImageView
addSubview:bgImageView2];
UILabel
*label = [[UILabel
alloc]initWithFrame:CGRectMake(bgView.frame.origin.x + 61 ,
bg1.frame.size.height / 2 + 20, 100, 20)];
label.text =
@"加载中...";
[bgImageView
addSubview:label];
UIButton
*button = [[UIButton alloc]initWithFrame:CGRectMake(200, 100, 60,
30)];
button.backgroundColor = [UIColor redColor];
[button
setTitle:@"开始" forState:UIControlStateNormal];
[self.view
addSubview:button];
[button
addTarget:self action:@selector(startRotate)
forControlEvents:UIControlEventTouchUpIns ide];
UIButton
*button1 = [[UIButton alloc]initWithFrame:CGRectMake(50, 100, 60,
30)];
button1.backgroundColor = [UIColor redColor];
[self.view
addSubview:button1];
[button1
setTitle:@"停止" forState:UIControlStateNormal];
[button1
addTarget:self action:@selector(stopRotate)
forControlEvents:UIControlEventTouchUpIns ide];
}
- (void) rotateWithOptions: (UIViewAnimationOptions) options {
[UIView
animateWithDuration: 0.125f
delay: 0.0f
options: options
animations: ^{
bgImageView2.transform =
CGAffineTransformRotate(bgImageView2.transform, M_PI / 2);
}
completion: ^(BOOL finished) {
if (finished) {
if (animating) {
[self rotateWithOptions: UIViewAnimationOptionCur veLinear];
} else if (options != UIViewAnimationOptionCur veEaseOut) {
[self rotateWithOptions: UIViewAnimationOptionCur veEaseOut];
}
}
}];
}
- (void) startRotate {
if
(!animating) {
animating = YES;
[self rotateWithOptions: UIViewAnimationOptionCur veEaseIn];
}
}
- (void) stopRotate{
animating =
NO;
}
//
//
//
//
//
//
#import "ViewController.h"
@interface ViewController ()
{
}
@end
@implementation ViewController
- (void)viewDidLoad {
}
- (void) rotateWithOptions: (UIViewAnimationOptions) options {
}
- (void) startRotate {
}
- (void) stopRotate{
}