Custom image for UIDocumentMenuViewController only shows blue box

665 Views Asked by At

I'm trying to add a custom icon for a UIDocumentMenuViewController but the only thing that appears is a blue square. I've tried it with different files too.

@IBAction func importAction(sender: UIButton) {

        let importMenu: UIDocumentMenuViewController = UIDocumentMenuViewController(documentTypes: ["public.audio"], inMode: .Import)

         let img = UIImage(named: "MusicIcon.png")!

        importMenu.addOptionWithTitle("Music Library", image: img, order: UIDocumentMenuOrder.First, handler:{ self.musicPicker()})


        importMenu.delegate = self

        self.presentViewController(importMenu, animated: true, completion: nil)

    }

I also tried img.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) but that doesn't do anything either.

Any idea how to fix this?

2

There are 2 best solutions below

0
On

Your image is just big, make it smaller around 45x45, you adjust it.

0
On

Only image transparency is used to render the icon (similar to tab icons). You are probably not using a proper icon (whole icon is opaque so it becomes whole blue).