Swift interface builder問題

來源:互聯網
上載者:User

標籤:

 

1. 建立一個view檔案,如何用interface builder 將控制項串連到code?

2. 如何調整控制項間的距離?

2. 手動將button和action加入view

class RatingControl: UIView {

     // MARK: Initialization

    required init(coder aDecoder: NSCoder) {

        super.init(coder: aDecoder)        

        let button = UIButton(frame: CGRect(x: 0,y: 0,width: 44, height: 44))

        button.backgroundColor = UIColor.redColor()

        button.addTarget(self, action: "rattingButtonTapped", forControlEvents: .TouchDown)

        addSubview(button)

    }

 

    

    // MARK: Button actoin

    func ratingButtonTapped(button: UIButton) {

        print("Button pressed!")

    }

}

Swift interface builder問題

相關文章

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.