Swift -UIButton和UIImageView的用法


class ViewController: UIViewController {


    override func viewDidLoad() {

        super.viewDidLoad()

        let imageView : UIImageView = UIImageView(frame:CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))

        let imag : UIImage! = UIImage(named:"pic_zhuanjiajieshao")

        imageView.image = imag

        //imageView.sizeToFit()

        self.view.addSubview(imageView)

        

        let nameText : UITextField = UITextField(frame: CGRectMake(0, 300, self.view.bounds.size.width, 30))

        nameText.placeholder = "请输入账号名"

        self.view.addSubview(nameText)

        nameText.backgroundColor = UIColor.whiteColor()

        

        let login = UIButton(frame: CGRectMake(0,400,self.view.bounds.size.width,30))

        login.backgroundColor = UIColor.greenColor()

        self.view.addSubview(login)

        login.setTitle("登陆", forState: UIControlState.Normal)

        login.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)

        login.addTarget(self, action: #selector(buttonClick), forControlEvents: UIControlEvents.TouchUpInside)

        

        

    }

    func buttonClick(sender:UIButton!){

        print("click")

    }

    

    


}


阅读更多
个人分类: swift
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭