How can I add a ActivityItem to upper activity bar in UIActivityViewController?

后端 未结 3 559
一生所求
一生所求 2020-12-14 20:08

I like to add my own WhatsApp ActivityItem to the UIActivityViewController, but it is always added to the lower non colored activity bar, but I lik

相关标签:
3条回答
  • 2020-12-14 20:47

    In Swift,

    override static func activityCategory() -> UIActivityCategory
    {
        return .Share
    }
    
    0 讨论(0)
  • 2020-12-14 20:51

    Swift 3 version:

    public override static var activityCategory: UIActivityCategory {
        return .share;
    }
    
    0 讨论(0)
  • 2020-12-14 20:52

    In your custom UIActivity subclass you have to simply override one method:

    + (UIActivityCategory)activityCategory
    {
       return UIActivityCategoryShare;
    }
    

    There are to possible categories: action and share.
    It's important, this is class method, not instance. Also, it's iOS 7 specific - all action activities are placed in bottom line (if any), then above the share activities and then above AirDrop. So, if you want to get rid of bottom line for example, simply exclude all action activities. If you want to put something in share/action line - override activityCategory. default is UIActivityCategoryShare;

    0 讨论(0)
提交回复
热议问题