0

如何在圆圈的部分添加图像UIActivityController?我不需要它包含在共享部分中,我想在此处添加它。我试过了:

ac.tabBarItem.image = UIImage(named: "uLogo")

let items:[Any] = [UIImage(named: "uLogo"), "What do you think of my Take on the uSTADIUM App? Sign up so you can bet with or against me!", url]
let ac = UIActivityViewController(activityItems: items, applicationActivities: [])

哪个不起作用,所以不知道如何做到这一点

在此处输入图像描述

4

1 回答 1

1

你可以试试定制UIActivityViewController

class ActivityCtrl: UIActivityViewController{
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        if let cls = NSClassFromString("LPImageView"), let base = getBase(for: view, cls){
            for sub in base.subviews{
                if let img = sub as? UIImageView{
                    img.image = UIImage(named: "uLogo.png")
                    break
                }
            }
        }
    }
    
    
    
    func getBase(for v: UIView?, _ cls: AnyClass) -> UIView?{
           guard let vue = v else{ return nil }
           var result: UIView?
           for sub in vue.subviews{
               if sub.isKind(of: cls){
                   return sub
               }
               else {
                   result = getBase(for: sub, cls)
                   if result != nil{
                       return result
                   }
               }
           }
           return result
       }
}

用法:

if let url = URL(string: "https://www.baidu.com"), let img = UIImage(named: "uLogo"){
            let items:[Any] = [img, "What do you think of my Take on the uSTADIUM App? Sign up so you can bet with or against me!", url]
            let ac = ActivityCtrl(activityItems: items, applicationActivities: [])
            present(ac, animated: true){ }
        }

结果:

999


我怎么知道LPImageView

888

于 2021-10-29T03:42:27.690 回答