Fix Save to Photos UIActivity icon being stretched

This commit is contained in:
Shadowfacts 2024-03-20 12:29:10 -04:00
parent f9aee46bbe
commit 3ecee61013
1 changed files with 8 additions and 1 deletions

View File

@ -23,7 +23,14 @@ class SaveToPhotosActivity: UIActivity {
return "Save to Photos"
}
override var activityImage: UIImage? {
UIImage(systemName: "square.and.arrow.down")
// Just using the symbol image directly causes it to be stretched.
let symbol = UIImage(systemName: "square.and.arrow.down", withConfiguration: UIImage.SymbolConfiguration(scale: .large))!
let format = UIGraphicsImageRendererFormat()
format.scale = UIScreen.main.scale
return UIGraphicsImageRenderer(size: CGSize(width: 76, height: 76), format: format).image { ctx in
let rect = AVMakeRect(aspectRatio: symbol.size, insideRect: CGRect(x: 0, y: 0, width: 76, height: 76))
symbol.draw(in: rect)
}
}
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {