07

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];

    

    //打开交互

    imageView.userInteractionEnabled = YES;

    

    imageView.backgroundColor = [UIColor greenColor];

    [self.view addSubview:imageView];

    

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

    button.frame = CGRectMake(50, 50, 150, 80);

    [button setTitle:@"响应者链" forState:UIControlStateNormal];

    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    button.titleLabel.font = [UIFont boldSystemFontOfSize:19];//按钮是个组合控件

    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];

    [imageView addSubview:button];

}

    

 - (void)click {

        NSLog(@"别摸我");

    }

 

posted @ 2016-02-23 08:53  whwhll  阅读(146)  评论(0编辑  收藏  举报