//
// ViewController.m
// OCGuoQi
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 apple . All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
{ UIView *redView;
UIButton *button;
int flag;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
redView = [[UIView alloc] init];
redView.frame = CGRectMake(50,400,30,30);
redView.backgroundColor = UIColor.redColor;
[self.view addSubview:redView];
UIView *whiteColor = [[UIView alloc] initWithFrame:(CGRectMake(12,6,6,18))];
whiteColor.backgroundColor = UIColor.whiteColor;
[redView addSubview:whiteColor];
UIView *whitColor = [[UIView alloc] initWithFrame:(CGRectMake(6,12,18,6))];
whitColor.backgroundColor = UIColor.whiteColor;
[redView addSubview:whitColor];
//图片的显示
UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(100,200,200,200);
[self.view addSubview:imageView];
[imageView initWithImage:[UIImage imageNamed:@"1"]];
//按钮的创建
button =[UIButton buttonWithType:(UIButtonTypeSystem)];
button.frame = CGRectMake(0,100,50,50);
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button addTarget:self action:@selector(did) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button];
//手势的定义
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
// [tap addTarget:self action:@selector(did)];
// [self.view addGestureRecognizer:tap];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)did{
NSLog(@"滴滴");
[UIView animateWithDuration:5 animations:^{
if (flag == 0) {
redView.frame = CGRectMake(50,40,30,30);
flag = 1;
}
else {
redView.frame = CGRectMake(50,400,30,30);
flag = 0;
}
}];
}
@end
// ViewController.m
// OCGuoQi
//
// Created by apple on 14-7-8.
// Copyright (c) 2014年 apple . All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
{ UIView *redView;
UIButton *button;
int flag;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
redView = [[UIView alloc] init];
redView.frame = CGRectMake(50,400,30,30);
redView.backgroundColor = UIColor.redColor;
[self.view addSubview:redView];
UIView *whiteColor = [[UIView alloc] initWithFrame:(CGRectMake(12,6,6,18))];
whiteColor.backgroundColor = UIColor.whiteColor;
[redView addSubview:whiteColor];
UIView *whitColor = [[UIView alloc] initWithFrame:(CGRectMake(6,12,18,6))];
whitColor.backgroundColor = UIColor.whiteColor;
[redView addSubview:whitColor];
//图片的显示
UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(100,200,200,200);
[self.view addSubview:imageView];
[imageView initWithImage:[UIImage imageNamed:@"1"]];
//按钮的创建
button =[UIButton buttonWithType:(UIButtonTypeSystem)];
button.frame = CGRectMake(0,100,50,50);
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button addTarget:self action:@selector(did) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button];
//手势的定义
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
// [tap addTarget:self action:@selector(did)];
// [self.view addGestureRecognizer:tap];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)did{
NSLog(@"滴滴");
[UIView animateWithDuration:5 animations:^{
if (flag == 0) {
redView.frame = CGRectMake(50,40,30,30);
flag = 1;
}
else {
redView.frame = CGRectMake(50,400,30,30);
flag = 0;
}
}];
}
@end