swift基礎控制項的建立

來源:互聯網
上載者:User

標籤:swift   控制項   基礎   

 /*        let apples = 3        let orange = 5        let L = 1.1        let appleSummary = "I have \(apples) apples"        let fruitSummary = "I have \(apples + orange) pieces of fruit."        let isay = "I Love \(L) you "        print(isay)        let expliciFloat: Float = 4//        print(fruitSummary)        print(expliciFloat)        let label = "label"        let width = 94        let widthlabel = label + String(width)        print(widthlabel)        */        /*初始化一個數組有值數組*/        var shoppingList = ["catfish","water","tulips","agg","water"]        var dic = [            "A":"a",            "B":"b",        ]        shoppingList[1] = "aaaaaa"//        print(shoppingList[0])        /*初始化一個空的數組和字典*///        let emptyArray = String["",""]()         let emptyDictionary = Dictionary<String, Float >()        print(emptyDictionary)        let textLabel = UILabel (frame:CGRectMake(self.view.frame.size.width/8,20,self.view.frame.size.width*3/4,100))//        給label 設值        textLabel.text = "現在我們來開始學習如何建立我們的第一個swift控制項吧 -UILabel"//        設定是否預設換行        textLabel.numberOfLines = 0//        設定label的背景顏色        var whitColor = UIColor(red:1.0,green:1.0,blue:1.0,alpha:1.0)        textLabel.backgroundColor = whitColor        self.view.addSubview(textLabel)        //view        let view  = UIView (frame: CGRectMake(100, 100, 100, 100))        view.backgroundColor = UIColor.blueColor()        self.view.addSubview(view)        //textfield        let textfield = UITextField(frame: CGRectMake(20, 200, 200, 50))        textfield.text = "哈哈"        textfield.textColor = UIColor.redColor()        self.view.addSubview(textfield)        //button        let button = UIButton(frame: CGRectMake( 20, 250, 150, 30))        button.backgroundColor = UIColor.purpleColor()        button.titleLabel?.text = "1111"        button.addTarget(self, action:Selector("buttonClick:")  , forControlEvents: UIControlEvents.TouchUpInside)        self.view.addSubview(button)        //imageview        let imageview = UIImageView (frame: CGRectMake(20, 300, 300, 300))        imageview.image = UIImage(named: "Unknown")        self.view.addSubview(imageview)    }    //按鈕監聽    func buttonClick(btn:UIButton){            print(btn.titleLabel?.text)        }![如](http://img.blog.csdn.net/20150605234753408)

swift基礎控制項的建立

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.