【问题标题】:Make a UIButton programmatically in Swift在 Swift 中以编程方式制作 UIButton
【发布时间】:2014-07-28 22:13:02
【问题描述】:

我正在尝试使用 Swift 以编程方式构建 UI。

我怎样才能让这个动作起作用?

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let myFirstLabel = UILabel()
    let myFirstButton = UIButton()
    myFirstLabel.text = "I made a label on the screen #toogood4you"
    myFirstLabel.font = UIFont(name: "MarkerFelt-Thin", size: 45)
    myFirstLabel.textColor = UIColor.redColor()
    myFirstLabel.textAlignment = .Center
    myFirstLabel.numberOfLines = 5
    myFirstLabel.frame = CGRectMake(15, 54, 300, 500)
    myFirstButton.setTitle("✸", forState: .Normal)
    myFirstButton.setTitleColor(UIColor.blueColor(), forState: .Normal)
    myFirstButton.frame = CGRectMake(15, -50, 300, 500)
    myFirstButton.addTarget(self, action: "pressed", forControlEvents: .TouchUpInside)
    self.view.addSubview(myFirstLabel)
    self.view.addSubview(myFirstButton)
}

func pressed(sender: UIButton!) {
    var alertView = UIAlertView();
    alertView.addButtonWithTitle("Ok");
    alertView.title = "title";
    alertView.message = "message";
    alertView.show();
}

【问题讨论】:

    标签: ios swift xcode cocoa-touch uibutton


    【解决方案1】:

    您只是缺少选择器名称末尾的冒号。由于pressed 需要一个参数,所以冒号必须在那里。此外,您的按下功能不应嵌套在 viewDidLoad 内。

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let myFirstLabel = UILabel()
        let myFirstButton = UIButton()
        myFirstLabel.text = "I made a label on the screen #toogood4you"
        myFirstLabel.font = UIFont(name: "MarkerFelt-Thin", size: 45)
        myFirstLabel.textColor = .red
        myFirstLabel.textAlignment = .center
        myFirstLabel.numberOfLines = 5
        myFirstLabel.frame = CGRect(x: 15, y: 54, width: 300, height: 500)
        myFirstButton.setTitle("✸", for: .normal)
        myFirstButton.setTitleColor(.blue, for: .normal)
        myFirstButton.frame = CGRect(x: 15, y: -50, width: 300, height: 500)
        myFirstButton.addTarget(self, action: #selector(pressed), for: .touchUpInside)
    }
    
    @objc func pressed() {
        var alertView = UIAlertView()
        alertView.addButtonWithTitle("Ok")
        alertView.title = "title"
        alertView.message = "message"
        alertView.show()
    }
    

    编辑:更新以反映 Swift 2.2 中的最佳实践。应该使用 #selector() 而不是已弃用的文字字符串。

    【讨论】:

    • 当我按下按钮时,应用程序仍然崩溃。
    • 抱歉已修复。该函数不应嵌套。
    • 嘿,你能告诉我冒号后面的逻辑我们需要在代表动作的字符串后面添加吗?
    • @chorajunior 需要冒号,因为pressed 函数需要一个参数。
    • 相反,任何阅读本文的人可能还想知道,如果您的按钮操作引用了不带参数的函数,则不需要冒号,如果不删除冒号甚至可能导致错误。
    【解决方案2】:

    是的,在模拟器中。有时它不会识别选择器,似乎存在错误。即使我没有遇到您的代码,我也只是更改了操作名称(选择器)。有效

    let buttonPuzzle:UIButton = UIButton(frame: CGRectMake(100, 400, 100, 50))
    buttonPuzzle.backgroundColor = UIColor.greenColor()
    buttonPuzzle.setTitle("Puzzle", forState: UIControlState.Normal)
    buttonPuzzle.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
    buttonPuzzle.tag = 22;
    self.view.addSubview(buttonPuzzle)
    

    这里有一个示例选择器函数:

    func buttonAction(sender:UIButton!) {
        var btnsendtag:UIButton = sender
        if btnsendtag.tag == 22 {            
            //println("Button tapped tag 22")
        }
    }
    

    【讨论】:

      【解决方案3】:

      您应该能够通过访问 UIButtontitleLabel 属性以编程方式创建自定义 UI 按钮。

      Per Class Reference in Swift:关于 titleLabel 属性,它说“虽然这个属性是只读的,但它自己的属性是读/写的。主要使用这些属性来配置文本按钮。”

      Swift中,可以直接修改titleLabel的属性,如下:

      let myFirstButton = UIButton()
      myFirstButton.titleLabel!.text = "I made a label on the screen #toogood4you"
      myFirstButton.titleLabel!.font = UIFont(name: "MarkerFelt-Thin", size: 45)
      myFirstButton.titleLabel!.textColor = UIColor.red
      myFirstButton.titleLabel!.textAlignment = .center
      myFirstButton.titleLabel!.numberOfLines = 5
      myFirstButton.titleLabel!.frame = CGRect(x: 15, y: 54, width: 300, height: 500)
      

      编辑

      Swift 3.1 语法

      【讨论】:

      • 我尝试运行此代码,但它不适合我。 titleLabel 的孩子似乎不存在
      【解决方案4】:

      Swift:以编程方式创建 Ui 按钮

      let myButton = UIButton() 
      myButton.titleLabel!.frame = CGRectMake(15, 54, 300, 500) 
      myButton.titleLabel!.text = "Button Label"
      myButton.titleLabel!.textColor = UIColor.redColor()
      myButton.titleLabel!.textAlignment = .Center
      

      【讨论】:

        【解决方案5】:

        在 Swift 中,我们可以通过在 viewcontroller.swift 文件中编写此代码以编程方式制作按钮...

        import UIKit
        
        class ViewController: UIViewController
        {  
        private let firstbutton:UIButton = UIButton()
        
        override func viewDidLoad() {
            super.viewDidLoad()
            self.firstbutton = UIButton.buttonWithType(UIButtonType.Custom) as? UIButton
            self.firstbutton!.frame = CGRectMake(100, 200, 100, 100)
            self.firstbutton!.backgroundColor = UIColor.redColor()
            self.firstbutton!.setTitle("My Button", forState: UIControlState.Normal)
            self.firstbutton!.addTarget(self, action:#selector(self.firstButtonClicked), forControlEvents: .TouchUpInside)
            self.view.addSubview(firstbutton!)
            }
        
        func firstButtonClicked(){
           print("First Button Clicked")
        }
        

        【讨论】:

        • 没有@objc 的选择器功能是不接受的。
        【解决方案6】:

        试试这些……希望对你有帮助……

        override func viewDidLoad() {
        super.viewDidLoad()  
        
            let btn = UIButton()
            btn.frame = CGRectMake(10, 10, 50, 50)  //set frame
            btn.setTitle("btn", forState: .Normal)  //set button title
            btn.setTitleColor(UIColor.redColor(), forState: .Normal) //set button title color
            btn.backgroundColor = UIColor.greenColor() //set button background color
            btn.tag = 1 // set button tag
            btn.addTarget(self, action: "btnclicked:", forControlEvents: .TouchUpInside) //add button action
            self.view.addSubview(btn) //add button in view
        
        }
        

        这些是按钮点击事件..

        func btnclicked(sender: UIButton!) 
        {
            //write the task you want to perform on buttons click event..
        }
        

        【讨论】:

          【解决方案7】:

          iOS 9.1/Xcode 7.1.1/Swift 2.1 中带有约束的 UIButton:

          import UIKit
          import MapKit
          
          class MapViewController: UIViewController {  
          
              override func loadView() {
                  mapView = MKMapView()  //Create a view...
                  view = mapView         //assign it to the ViewController's (inherited) view property.
                                         //Equivalent to self.view = mapView
          
                  myButton = UIButton(type: .RoundedRect)  //RoundedRect is an alias for System (tested by printing out their rawValue's)
                  //myButton.frame = CGRect(x:50, y:500, width:70, height:50)  //Doesn't seem to be necessary when using constraints.
                  myButton.setTitle("Current\nLocation", forState: .Normal)
                  myButton.titleLabel?.lineBreakMode = .ByWordWrapping  //If newline in title, split title onto multiple lines
                  myButton.titleLabel?.textAlignment = .Center
                  myButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
                  myButton.layer.cornerRadius = 6   //For some reason, a button with type RoundedRect has square corners
                  myButton.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5) //Make the color partially transparent
                  //Attempt to add padding around text. Shrunk the frame when I tried it.  Negative values had no effect.
                  //myButton.titleEdgeInsets = UIEdgeInsetsMake(-10,-10,-10,-10)
                  myButton.contentEdgeInsets = UIEdgeInsetsMake(5,5,5,5)  //Add padding around text.
          
                  myButton.addTarget(self, action: "getCurrentLocation:", forControlEvents: .TouchUpInside)
                  mapView.addSubview(myButton)
          
                  //Button Constraints:
                  myButton.translatesAutoresizingMaskIntoConstraints = false //***
                  //bottomLayoutGuide(for tab bar) and topLayoutGuide(for status bar) are properties of the ViewController
                  //To anchor above the tab bar on the bottom of the screen:
                  let bottomButtonConstraint = myButton.bottomAnchor.constraintEqualToAnchor(bottomLayoutGuide.topAnchor, constant: -20) //Implied call of self.bottomLayoutGuide. Anchor 20 points **above** the top of the tab bar.
                  //To anchor to the blue guide line that is inset from the left 
                  //edge of the screen in InterfaceBuilder:
                  let margins = view.layoutMarginsGuide  //Now the guide is a property of the View.
                  let leadingButtonConstraint = myButton.leadingAnchor.constraintEqualToAnchor(margins.leadingAnchor)
          
                  bottomButtonConstraint.active = true
                  leadingButtonConstraint.active = true
              }
          
          
              func getCurrentLocation(sender: UIButton) {
                  print("Current Location button clicked!")
              }
          

          按钮固定在标签栏上方的左下角。

          【讨论】:

          • 请问getCurrentLocation如何帮助我们获取位置?
          • @nyxee,这里的问题是关于如何以编程方式制作按钮。获取用户的位置与制作按钮无关。要获取用户的位置,请参见此处; developer.apple.com/reference/corelocation/cllocationmanager。如果您无法弄清楚,请提出您自己的问题。
          【解决方案8】:

          Swift 2.2 Xcode 7.3

          由于按钮回调方法现在不推荐使用 Objective-C 字符串文字

          let button:UIButton = UIButton(frame: CGRectMake(100, 400, 100, 50))
          button.backgroundColor = UIColor.blackColor()
          button.setTitle("Button", forState: UIControlState.Normal)
          button.addTarget(self, action:#selector(self.buttonClicked), forControlEvents: .TouchUpInside)
          self.view.addSubview(button)
          
          func buttonClicked() {
               print("Button Clicked")
          }
          

          Swift 3 Xcode 8

          let button:UIButton = UIButton(frame: CGRect(x: 100, y: 400, width: 100, height: 50))
          button.backgroundColor = .black
          button.setTitle("Button", for: .normal)
          button.addTarget(self, action:#selector(self.buttonClicked), for: .touchUpInside)
          self.view.addSubview(button)
          
          func buttonClicked() {
              print("Button Clicked")
          }
          

          Swift 4 Xcode 9

          let button:UIButton = UIButton(frame: CGRect(x: 100, y: 400, width: 100, height: 50))
          button.backgroundColor = .black
          button.setTitle("Button", for: .normal)
          button.addTarget(self, action:#selector(self.buttonClicked), for: .touchUpInside)
          self.view.addSubview(button)
          
          @objc func buttonClicked() {
              print("Button Clicked")
          }
          

          【讨论】:

          • @n.by.n 如何在该方法 buttonClicked() 上传递参数?
          【解决方案9】:

          Swift:以编程方式创建 Ui 按钮,

          var button: UIButton = UIButton(type: .Custom)
          
          button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0)
          
          button.addTarget(self, action: #selector(self.aMethod), forControlEvents: .TouchUpInside)
          
          button.tag=2
          
          button.setTitle("Hallo World", forState: .Normal)
          
          view.addSubview(button)
          
          
          func aMethod(sender: AnyObject) {
              print("you clicked on button \(sender.tag)")
          }
          

          【讨论】:

            【解决方案10】:

            对于 Swift 3 Xcode 8.......

            let button = UIButton(frame: CGRect(x: 0, y: 0, width: container.width, height: container.height))
                    button.addTarget(self, action: #selector(self.barItemTapped), for: .touchUpInside)
            
            
            func barItemTapped(sender : UIButton) {
                //Write button action here
            }
            

            【讨论】:

              【解决方案11】:

              斯威夫特 4/5

              let button = UIButton(frame: CGRect(x: 20, y: 20, width: 200, height: 60))
               button.setTitle("Email", for: .normal)
               button.backgroundColor = .white
               button.setTitleColor(UIColor.black, for: .normal)
               button.addTarget(self, action: #selector(self.buttonTapped), for: .touchUpInside)
               myView.addSubview(button)
              
              
              
              @objc func buttonTapped(sender : UIButton) {
                              //Write button action here
                          }
              

              【讨论】:

                【解决方案12】:

                Swift 3:您可以通过编程方式创建 UIButton

                在方法范围内,例如在ViewDidLoad() 一定要给按钮添加约束,否则看不到

                let button = UIButton()
                button.translatesAutoresizingMaskIntoConstraints = false
                button.target(forAction: #selector(buttonAction), withSender: self)
                //button.backgroundColor etc
                
                view.addSubview(button)
                
                @objc func buttonAction() {
                   //some Action
                }
                

                或在您的范围之外作为全局变量从您的module 中的任何位置访问它

                let button: UIButton = {
                   let b = UIButton()
                   b.translatesAutoresizingMaskIntoConstraints = false
                   //b.backgroundColor etc
                   return b
                }()
                

                然后你设置约束

                func setupButtonView() {
                   view.addSubview(button)
                   button.widthAnchor.constraint(equalToConstant: 40).isActive = true
                   button.heightAnchor.constraint(equalToConstant: 40).isActive = true
                   // etc
                
                }
                

                【讨论】:

                • '''@objc func buttonAction() { //some Action }'''.
                【解决方案13】:

                斯威夫特 4

                private func createButton {
                    let sayButtonT = UIButton(type: .custom)
                    sayButtonT.addTarget(self, action: #selector(sayAction(_:)), for: .touchUpInside)
                }
                
                @objc private func sayAction(_ sender: UIButton?) {
                
                }
                

                【讨论】:

                  【解决方案14】:

                  UIButton 的 Swift“按钮工厂”扩展(当我们使用它时)也适用于 UILabel,如下所示:

                  extension UILabel
                  {
                  // A simple UILabel factory function
                  // returns instance of itself configured with the given parameters
                  
                  // use example (in a UIView or any other class that inherits from UIView):
                  
                  //   addSubview(   UILabel().make(     x: 0, y: 0, w: 100, h: 30,
                  //                                   txt: "Hello World!",
                  //                                 align: .center,
                  //                                   fnt: aUIFont,
                  //                              fntColor: UIColor.red)                 )
                  //
                  
                  func make(x: CGFloat, y: CGFloat, w: CGFloat, h: CGFloat,
                            txt: String,
                            align: NSTextAlignment,
                            fnt: UIFont,
                            fntColor: UIColor)-> UILabel
                  {
                      frame = CGRect(x: x, y: y, width: w, height: h)
                      adjustsFontSizeToFitWidth = true
                      textAlignment = align
                      text = txt
                      textColor = fntColor
                      font = fnt
                      return self
                  }
                  // Of course, you can make more advanced factory functions etc.
                  // Also one could subclass UILabel, but this seems to be a     convenient case for an extension.
                  }
                  
                  
                  extension UIButton
                  {
                  // UIButton factory returns instance of UIButton
                  //usage example:
                  
                  // addSubview(UIButton().make(x: btnx, y:100, w: btnw, h: btnh,
                  // title: "play", backColor: .red,
                  // target: self,
                  // touchDown: #selector(play), touchUp: #selector(stopPlay)))
                  
                  
                  func make(   x: CGFloat,y: CGFloat,
                               w: CGFloat,h: CGFloat,
                                    title: String, backColor: UIColor,
                                    target: UIView,
                                    touchDown:  Selector,
                                    touchUp:    Selector ) -> UIButton
                  {
                      frame = CGRect(x: x, y: y, width: w, height: h)
                      backgroundColor = backColor
                      setTitle(title, for: .normal)
                      addTarget(target, action: touchDown, for: .touchDown)
                      addTarget(target, action: touchUp  , for: .touchUpInside)
                      addTarget(target, action: touchUp  , for: .touchUpOutside)
                  
                      return self
                  }
                  }
                  

                  在 Xcode 版本 9.2 (9C40b) Swift 4.x 中在 Swift 中测试

                  【讨论】:

                    【解决方案15】:

                    如果您进入主情节提要部分,然后在右下角转到带有正方形的圆圈,然后使用空白按钮。然后在代码中使用@IBAction 来连接它。然后你可以用它创建一个@IBAction 函数。

                    【讨论】:

                      【解决方案16】:

                      iOS 12、Swift 4.2 和 XCode 10.1

                      //For system type button
                      let button = UIButton(type: .system)
                      button.frame = CGRect(x: 100, y: 250, width: 100, height: 50)
                      //        button.backgroundColor = .blue
                      button.setTitle("Button", for: .normal)
                      button.setTitleColor(.white, for: .normal)
                      button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 13.0)
                      button.titleLabel?.textAlignment = .center//Text alighment center
                      button.titleLabel?.numberOfLines = 0//To display multiple lines in UIButton
                      button.titleLabel?.lineBreakMode = .byWordWrapping//By word wrapping
                      button.tag = 1//To assign tag value
                      button.btnProperties()//Call UIButton properties from extension function
                      button.addTarget(self, action:#selector(self.buttonClicked), for: .touchUpInside)
                      self.view.addSubview(button)
                      
                      //For custom type button (add image to your button)
                      let button2 = UIButton(type: .custom)
                      button2.frame = CGRect(x: 100, y: 400, width: 100, height: 50)
                      //        button2.backgroundColor = .blue
                      button2.setImage(UIImage.init(named: "img.png"), for: .normal)
                      button2.tag = 2
                      button2.btnProperties()//Call UIButton properties from extension function
                      button2.addTarget(self, action:#selector(self.buttonClicked), for: .touchUpInside)
                      self.view.addSubview(button2)
                      
                      @objc func buttonClicked(sender:UIButton) {
                          print("Button \(sender.tag) clicked")
                      }
                      
                      //You can add UIButton properties like this also
                      extension UIButton {
                          func btnProperties() {
                              layer.cornerRadius = 10//Set button corner radious
                              clipsToBounds = true
                              backgroundColor = .blue//Set background colour
                              //titleLabel?.textAlignment = .center//add properties like this
                          }
                      }
                      

                      【讨论】:

                        【解决方案17】:

                        Swift 4.2 - XCode 10.1

                        使用闭包

                        let button: UIButton = {
                          let button = UIButton(type: .system)
                          button.titleLabel?.font = UIFont.systemFont(ofSize: 20)
                          ...
                          return button
                        }()
                        

                        【讨论】:

                        • 请记住,您不能在闭包内使用 addTarget 和 action。
                        【解决方案18】:

                        Swift 5.0

                                let button = self.makeButton(title: "Login", titleColor: .blue, font: UIFont.init(name: "Arial", size: 18.0), background: .white, cornerRadius: 3.0, borderWidth: 2, borderColor: .black)
                                view.addSubview(button)
                                // Adding Constraints
                                button.heightAnchor.constraint(equalToConstant: 40).isActive = true
                                button.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 40).isActive = true
                                button.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -40).isActive = true
                                button.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -400).isActive = true
                                button.addTarget(self, action: #selector(pressed(_ :)), for: .touchUpInside)
                        
                               // Define commmon method
                                func makeButton(title: String? = nil,
                                                   titleColor: UIColor = .black,
                                                   font: UIFont? = nil,
                                                   background: UIColor = .clear,
                                                   cornerRadius: CGFloat = 0,
                                                   borderWidth: CGFloat = 0,
                                                   borderColor: UIColor = .clear) -> UIButton {
                                let button = UIButton()
                                button.translatesAutoresizingMaskIntoConstraints = false
                                button.setTitle(title, for: .normal)
                                button.backgroundColor = background
                                button.setTitleColor(titleColor, for: .normal)
                                button.titleLabel?.font = font
                                button.layer.cornerRadius = 6.0
                                button.layer.borderWidth = 2
                                button.layer.borderColor = UIColor.red.cgColor
                                return button
                              }
                                // Button Action
                                 @objc func pressed(_ sender: UIButton) {
                                        print("Pressed")
                                  }
                        

                        【讨论】:

                          【解决方案19】:

                          在 iOS 15 中,Apple 引入了带有 Button 的配置(.gray().filled() 等)。配置选项还有很多。

                           var grayButton: UIButton!
                          
                           func addButton() {
                              grayButton = UIButton(configuration: .gray())
                              grayButton.addTarget(self, action: #selector(buttonPressed(_:)), for: .touchUpInside)
                              grayButton.frame = CGRect(x: 10, y: 50, width: 150, height: 50)
                              grayButton.configuration?.title = "Press Me"
                              grayButton.configuration?.subtitle = "Sub Title"
                              grayButton.configuration?.image = UIImage(systemName: "house")
                              grayButton.configuration?.imagePadding = 10
                              grayButton.configuration?.imagePlacement = .leading
                              view.addSubview(grayButton)
                          }
                          
                          @objc func buttonPressed(_ sender: UIButton) {
                              grayButton.configuration?.showsActivityIndicator = true
                              DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                                  self.grayButton.configuration?.showsActivityIndicator = false
                              }
                          }
                          

                          我们还可以使用showsActivityIndicator 属性在按钮内显示和隐藏活动指示器。

                          【讨论】:

                            【解决方案20】:

                            我已经给出了在编码中创建按钮和设置约束的示例。此代码还包含以编程方式执行的按钮操作。

                            import UIKit
                            
                            class ViewController: UIViewController {
                              
                              
                              lazy var button: UIButton! = {
                                
                                let button = UIButton()
                                button.translatesAutoresizingMaskIntoConstraints = false
                                button.backgroundColor = .darkGray
                                button.setTitleColor(.white, for: .normal)
                                button.addTarget(self, action: #selector(didTaped(_:)), for: .touchUpInside)
                                button.tag = 1
                                button.setTitle("Tap", for: .normal)
                                return button
                                
                              }()
                              
                              lazy var label: UILabel! = {
                                
                                let label = UILabel()
                                label.translatesAutoresizingMaskIntoConstraints = false
                                label.textColor = .black
                                label.font = .systemFont(ofSize: 17)
                                label.textAlignment = .center
                                return label
                                
                              }()
                                
                              override var preferredStatusBarStyle: UIStatusBarStyle{
                                return .darkContent
                              }
                              
                              override func viewDidLoad() {
                                super.viewDidLoad()
                                // Do any additional setup after loading the view.
                                self.view.backgroundColor = .white
                                self.setConstraint()
                                
                              }
                              
                              @objc func didTaped(_ sender: UIButton){
                                
                                self.label.text = "No of times Taped: \(sender.tag)"
                                self.button.tag += 1
                                
                              }
                              
                              func setConstraint(){
                                
                                self.view.addSubview(self.button)
                                self.view.addSubview(self.label)
                                
                                NSLayoutConstraint.activate([
                                
                                  self.button.heightAnchor.constraint(equalToConstant: 60),
                                  self.button.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width * 0.66),
                                  self.button.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
                                  self.button.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
                                  
                                  self.label.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
                                  self.label.topAnchor.constraint(equalTo: self.button.topAnchor, constant: UIScreen.main.bounds.height * 0.12),
                                  self.label.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 10),
                            
                                ])
                            
                              }
                              
                            }
                            

                            输出:

                            【讨论】:

                              猜你喜欢
                              • 1970-01-01
                              • 2015-11-20
                              • 2016-09-28
                              • 1970-01-01
                              • 1970-01-01
                              • 1970-01-01
                              • 2013-02-09
                              • 1970-01-01
                              • 2017-09-05
                              相关资源
                              最近更新 更多