你可以试试定制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){ }
}
结果:
我怎么知道LPImageView
?