我要制作UIActivityViewController
,如下图所示。我只需要自定义UIActivityViewController
的底部(位于空投部分下方)。
这是我要搜索的图像https://ibb.co/0sbfQMY
的链接这是我的代码,但是它完全改变了背景颜色。
let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: nil)
activityViewController.view.backgroundColor = UIColor.black.withAlphaComponent(0.8)
答案 0 :(得分:0)
要在创建视图之前设置视图背景颜色。展示控制器后,您必须设置颜色。这样做:
/*
* Sharing the app link
*/
private func shareApplication() {
let activityViewController = UIActivityViewController.init(activityItems: ["Message"], applicationActivities: [])
// This lines is for the popover you need to show in iPad
activityViewController.popoverPresentationController?.sourceView = (self.view)
// This line remove the arrow of the popover to show in iPad
activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.any
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)
// Anything you want to exclude
activityViewController.excludedActivityTypes = [
UIActivity.ActivityType.postToWeibo,
UIActivity.ActivityType.print,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.saveToCameraRoll,
UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.postToFlickr,
]
self.present(activityViewController, animated: true) {
//Here you need to set the color
activityViewController.view.backgroundColor = .red
}
}