Reputation: 21
I created custom UIActivity and override variable activityImage used my image.
fileprivate extension UIActivity.ActivityType {
static let extendedMessage =
UIActivity.ActivityType("ExtendedMessage")
}
Custom UIActivity:
fileprivate class ExtendedMessageActivity: UIActivity {
private let phoneNumbers: [String]
private var message: String?
init(phoneNumbers: [String]) {
self.phoneNumbers = phoneNumbers
super.init()
}
override static var activityCategory: UIActivity.Category {
return .share
}
override var activityType: UIActivity.ActivityType? { return .extendedMessage }
override var activityTitle: String? { return NSLocalizedString("Message", comment: "") }
override var activityImage: UIImage? {
return UIImage(named: "message-app-icon")
}
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
....
}
override func prepare(withActivityItems activityItems: [Any]) {
....
}
override func perform() {
....
}
}
The image appears in the set. I have a problem the image does not appear when it is in the "More" menu item. Why the image does not appear?
Upvotes: 2
Views: 264
Reputation: 156
Had tried to find documentation for the activity settings icon. Not found proper documentation. Just add the below code in your custom UIActivity, Working fine for me with Swift 5.2
@objc var _activitySettingsImage: UIImage? {
return UIImage(named: "activitySettingsIcon")
}
Don't forgot to activitySettingsIcon image set in 29pt.
Upvotes: 3
Reputation: 644
I solved the same issue by adding the following (in Objective C, but you get the idea).
- (UIImage *)_activitySettingsImage {
return [UIImage imageNamed:@"message-app-icon-for-setting"];
}
Apparently, image for more section should be smaller than the one in _activityImage. At the time of writing (XCode 12.3), 60pt for activityImage and 30pt for activitySettingsImage work for me. (I also added @2x for each image)..
Upvotes: 0