(001)UIView基础知识练习

1 // 2 // MainViewController.m 3 // TestUIView 4 // 5 // Created by alin on 14-6-18. 6 // Copyright (c) 2014年 ishitong. All rights reserved. 7 // 8 9 #import "MainViewController.h" 10 11 @interface MainViewController () 12 13 @end 14 15 @implementation MainViewController 16 17 - (void)viewDidLoad 18 { 19 [super viewDidLoad]; 20 21 } 22 23 - (void)didReceiveMemoryWarning 24 { 25 [super didReceiveMemoryWarning]; 26 } 27 28 - (IBAction)upClick:(id)sender { 29 30 [UIView beginAnimations:nil context:nil]; 31 [UIView setAnimationDuration:1.5]; 32 33 CGRect frame = _picBtn.frame; 34 frame.origin.y -= 50; 35 _picBtn.frame = frame; 36 37 [UIView commitAnimations]; 38 } 39 40 - (IBAction)downClick:(id)sender { 41 42 [UIView beginAnimations:nil context:nil]; 43 [UIView setAnimationDuration:1.5]; 44 45 CGRect frame = _picBtn.frame; 46 frame.origin.y += 50; 47 _picBtn.frame = frame; 48 49 [UIView commitAnimations]; 50 } 51 52 - (IBAction)leftClick:(id)sender { 53 54 [UIView beginAnimations:nil context:nil]; 55 [UIView setAnimationDuration:1.5]; 56 57 58 CGRect frame = _picBtn.frame; 59 frame.origin.x -= 50; 60 _picBtn.frame = frame; 61 62 [UIView commitAnimations]; 63 64 } 65 66 - (IBAction)rightClick:(id)sender { 67 68 [UIView beginAnimations:nil context:nil]; 69 [UIView setAnimationDuration:1.5]; 70 71 CGRect frame = _picBtn.frame; 72 frame.origin.x += 50; 73 _picBtn.frame = frame; 74 75 [UIView commitAnimations]; 76 } 77 78 - (IBAction)largerClick:(id)sender { 79 80 [UIView beginAnimations:nil context:nil]; 81 [UIView setAnimationDuration:1.5]; 82 83 CGAffineTransform tempTransform = _picBtn.transform; 84 _picBtn.transform = CGAffineTransformScale(tempTransform, 2.0, 2.0); 85 86 [UIView commitAnimations]; 87 } 88 89 - (IBAction)smallerClick:(id)sender { 90 91 [UIView beginAnimations:nil context:nil]; 92 [UIView setAnimationDuration:1.5]; 93 94 CGAffineTransform tempTransform = _picBtn.transform; 95 _picBtn.transform = CGAffineTransformScale(tempTransform, 0.5, 0.5); 96 97 [UIView commitAnimations]; 98 } 99 100 - (IBAction)leftRotate:(id)sender { 101 102 [UIView beginAnimations:nil context:nil]; 103 [UIView setAnimationDuration:1.5]; 104 105 //CGAffineTransform tempTransform = _picBtn.transform; 106 CGAffineTransform tempTransform = _picBtn.transform; 107 _picBtn.transform = CGAffineTransformRotate(tempTransform, -M_PI_4); 108 109 [UIView commitAnimations]; 110 } 111 112 - (IBAction)rightRotate:(id)sender { 113 114 [UIView beginAnimations:nil context:nil]; 115 [UIView setAnimationDuration:1.5]; 116 117 CGAffineTransform tempTransform = _picBtn.transform; 118 _picBtn.transform = CGAffineTransformRotate(tempTransform, M_PI_4); 119 120 [UIView commitAnimations]; 121 } 122 123 - (IBAction)rotate:(id)sender 124 { 125 if([sender tag] == 2) 126 { 127 [self myRotate:^{ 128 CGAffineTransform tempTransform = _picBtn.transform; 129 _picBtn.transform = CGAffineTransformRotate(tempTransform, -M_PI_4); 130 }]; 131 } 132 else if([sender tag] == 3) 133 { 134 [self myRotate:^{ 135 CGAffineTransform tempTransform = _picBtn.transform; 136 _picBtn.transform = CGAffineTransformRotate(tempTransform, M_PI_4); 137 }]; 138 } 139 } 140 141 - (void) myRotate:(void(^)())rotateBlock 142 { 143 [UIView beginAnimations:nil context:nil]; 144 [UIView setAnimationDuration:1.5]; 145 146 rotateBlock(); 147 148 [UIView commitAnimations]; 149 } 150 151 - (IBAction)reset:(id)sender { 152 153 [UIView beginAnimations:nil context:nil]; 154 [UIView setAnimationDuration:1.5]; 155 156 _picBtn.transform = CGAffineTransformIdentity; 157 158 [UIView commitAnimations]; 159 } 160 @end
***万事万物都有裂痕,那是光照进来的地方***

浙公网安备 33010602011771号