How do I create a standard iOS Share button?

后端 未结 7 542
情话喂你
情话喂你 2020-12-30 19:13

The iOS Human Interface Guidelines say:

Use the system-provided Share button. Users are familiar with the meaning and behavior of thi

7条回答
  •  佛祖请我去吃肉
    2020-12-30 19:33

    Here is the code for Swift 3.

    func addShareBarButtonItem() {
    
        let shareButton = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: #selector(MyViewController.shareButtonPressed))
    
        self.navigationItem.rightBarButtonItem = shareButton
    }
    
    func shareButtonPressed() {
        //Do something now!
    }
    

提交回复
热议问题