Ios implements button color conversion and can zoom in, zoom out, and rotate. iosbutton
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
_ Window = [[ui1_walloc] initWithFrame: [UIScreenmainScreen]. bounds];
_ Window. backgroundColor = [UIColorwhiteColor];
[_ WindowmakeKeyAndVisible];
// Define a parent View
UIView * superView = [[UIViewalloc] initWithFrame: CGRectMake (65,65, 300,300)];
[_ Window addSubview: superView];
_ Views = [[NSMutableArrayalloc] init];
// Create seven subviews cyclically
For (int I = 0; I <7; I ++ ){
UIView * view = [[UIViewalloc] initWithFrame: CGRectMake (50,50, 250,250)];
// Set the random color
View. backgroundColor = [UIColorcolorWithRed: arc4random () % 10 *. 1 green: arc4random () % 10 *. 1 blue: arc4random () % 10 *. 1 alpha: 1];
[_ Window addSubview: view];
UIView * lastView = [_ viewslastObject];
If (lastView! = Nil ){
View. transform = CGAffineTransformScale (lastView. transform, 0.8, 0.8 );
}
[_ Views addObject: view];
}
// Add several buttons on the interface to implement different functions
UIButton * button1 = [UIButtonbuttonWithType: UIButtonTypeRoundedRect];
[Button1 setTitle: @ "Rotate" forState: UIControlStateNormal];
Button1.tag= 101;
Button1.frame = CGRectMake (50,320, 50, 30 );
[Button1 addTarget: selfaction: @ selector (buttonAction :) forControlEvents: UIControlEventTouchUpInside];
[_ Window addSubview: button1];
UIButton * button2 = [UIButtonbuttonWithType: UIButtonTypeRoundedRect];
[Button2 setTitle: @ "zoom in" forState: UIControlStateNormal];
Button2.tag= 102;
Button2.frame = CGRectMake (150,320, 50, 30 );
[Button2 addTarget: selfaction: @ selector (buttonAction :) forControlEvents: UIControlEventTouchUpInside];
[_ Window addSubview: button2];
UIButton * button3 = [UIButtonbuttonWithType: UIButtonTypeRoundedRect];
[Button3 setTitle: @ "" forState: UIControlStateNormal];
Button3.tag= 103;
Button3.frame = CGRectMake (250,320, 50, 30 );
[Button3 addTarget: selfaction: @ selector (buttonAction :) forControlEvents: UIControlEventTouchUpInside];
[_ Window addSubview: button3];
_ Index = 0;
Return YES;
}
// Button click event
-(Void) buttonAction :( UIButton *) button {
If (button. tag = 103 ){
For (UIView * viewin _ views ){
View. transform = CGAffineTransformScale (view. transform,. 5,. 5 );
}
} Else if (button. tag = 102)
{
For (UIView * viewin _ views ){
View. transform = CGAffineTransformScale (view. transform, 2, 2 );
}
} Else {
// Enable a timer
[NSTimerscheduledTimerWithTimeInterval: 1 target: selfselector: @ selector (timeAction :) userInfo: nilrepeats: YES];
}
}
// Timer
-(Void) timeAction :( NSTimer *) time {
[UIViewbeginAnimations: nilcontext: nil];
[UIViewsetAnimationDuration: 1.9];
For (UIView * viewin _ views ){
View. backgroundColor = [UIColorcolorWithRed: arc4random () % 10 *. 1 green: arc4random () % 10 *. 1 blue: arc4random () % 10 *. 1 alpha: 1];
View. transform = CGAffineTransformRotate (view. transform, M_PI/10 );
}
[UIViewcommitAnimations];
_ Index ++;
If (_ index = 10 ){
For (UIView * viewin _ views ){
[View removeFromSuperview];
}
[Time invalidate];
}
}
The interface opened by the simulator is rotated to zoom in and out