IOS learning-animation effect implementation
//
// ViewController. m
// UI-animation exercises
//
// Created by jzq_macon 15/7/22.
// Copyright (c) jzq_mac. All rights reserved.
//
# Import ViewController. h
@ Interface ViewController ()
{
UIImageView * animation;
UIView * view;
UIView * view1;
}
@ End
@ Implementation ViewController
-(Void) viewDidLoad {
[Super viewDidLoad];
[Self creatView];
[NSTimer scheduledTimerWithTimeInterval: 10 target: self selector: @ selector (creatView) userInfo: nil repeats: YES];
}
-(Void) creatView
{
// Dynamic graph and move it
Animation = [[UIImageView alloc] initWithFrame: CGRectMake (86, 0,200,200)];
Animation. layer. cornerRadius = 100;
Animation. layer. masksToBounds = YES;
NSMutableArray * list = [NSMutableArray array];
For (int I = 1; I <= 15; I ++ ){
NSString * name = [NSString stringWithFormat: @ dynamic cat-% d (dragged). tiff, I];
[List addObject: [UIImage imageNamed: name];
}
Animation. animationImages = list;
Animation. animationDuration = 5;
Animation. animationRepeatCount =-1;
[Animation startAnimating];
[UIView animateWithDuration: 5 animations: ^ {animation. frame = CGRectMake (86,500,200,200);} completion: ^ (BOOL finishied) {[UIView animateWithDuration: 5 animations: ^ {animation. frame = CGRectMake (86, 0,200,200) ;}];
[Self. view addSubview: animation];
// Move the view
Self. view. backgroundColor = [UIColor grayColor];
View = [[UIView alloc] initWithFrame: CGRectMake (0, 0,100,100)];
View. backgroundColor = [UIColor redColor];
View. layer. cornerRadius = 50;
[Self. view addSubview: view];
[UIView animateWithDuration: 5 animations: ^ {view. frame = CGRectMake (275,550,100,100);} completion: ^ (BOOL finished) {[UIView animateWithDuration: 5 animations: ^ {view. frame = CGRectMake (0, 0,100,100) ;}];
View. alpha = 1;
[UIView animateWithDuration: 10 animations: ^ {view. alpha = 0;}];
View1 = [[UIView alloc] initWithFrame: CGRectMake (275, 0,100,100)];
View1.backgroundColor = [UIColor yellowColor];
View1.layer. cornerRadius = 50;
[Self. view addSubview: view1];
View1.alpha = 1;
[UIView animateWithDuration: 10 animations: ^ {view1.alpha = 0 ;}];
[UIView progress: 5 animations: ^ {view1.frame = CGRectMake (0,550,100,100);} completion: ^ (BOOL finished) {[UIView animateWithDuration: 5 animations: ^ {view1.frame = CGRectMake (275, 0,100,100) ;}];
}
//-(Void) click :( UIButton *) sender
//{
// If (sender. selected! = YES ){
// Sender. selected = YES;
// [Animation startAnimating];
// [Sender setTitle: @ start forState: UIControlStateNormal];
//
//} Else {
// Sender. selected = NO;
// [Animation stopAnimating];
// [Sender setTitle: @ pause forState: UIControlStateSelected];
//}
//}
-(Void) didReceiveMemoryWarning {
[Super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@ End