//
//  ViewController.swift
//  buttondemo
//
//  Created by Andy on 2019/1/29.
//  Copyright © 2019 Limi. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let button = UIButton.init(type: .custom)
        let buttonimg = UIButton(type: .custom)
        button.frame = CGRect(origin: .init(x: 50, y: 500), size: .init(width: 100, height: 100))
        button.backgroundColor = .red
        buttonimg.frame = CGRect(origin: .init(x: 50, y: 50), size: .init(width: 300, height: 300))
        buttonimg.backgroundColor = .black
        button.setTitle("请点击", for: .normal)
        button.setTitleColor(UIColor.red, for: .normal)
        button.addTarget(self, action: #selector(dianji), for: .touchUpInside)
        
        view.addSubview(button)
        view.addSubview(buttonimg)
    }
    
    
    @IBAction func dianji(){
      var a =  self.buttonimg.frame
    //这里会报错,求解,实在是不知道怎么搞了
    //Value of type 'ViewController' has no member 'buttonimg'
   //大意是:ViewController 没有 buttonimg这个对象
    print("hello")
    }
}