Hi,
I've been trying to follow your sample code to get the Toolbars to work but the icons just don't show up. None of the sample code works either, because it crashes saying "icons not found"
Here is the code I'm using for the toolbar:-
(Instantiating toolbar from IBOutlet)
/// Prepares the toolbar
private func prepareToolbar() {
// Title label.
toolbar.title = "Material"
toolbar.titleLabel.textColor = MaterialColor.white
// Detail label.
toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textColor = MaterialColor.white
var image: UIImage? = MaterialIcon.cm.menu
// Menu button.
let menuButton: IconButton = IconButton()
menuButton.pulseColor = MaterialColor.white
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
// Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
// Search button.
image = MaterialIcon.cm.search
let searchButton: IconButton = IconButton()
searchButton.pulseColor = MaterialColor.white
searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted)
/*
To lighten the status bar - add the
"View controller-based status bar appearance = NO"
to your info.plist file and set the following property.
*/
toolbar.backgroundColor = MaterialColor.blue.base
toolbar.leftControls = [menuButton]
toolbar.rightControls = [switchControl, searchButton]
}
Taking a look :)
So it looks like it is working to me. Icons are coming up as well. So what is your exact setup?
Material version (branch if not a release)?
Xcode version?
etc....

Toolbar project

Using storyboards example.

Hi,
I'm using XCode version 7.3 and iOS 9.3
This is how it looks on my emulator when I run that code:-

I tried importing my own image instead
let menuButton: IconButton = IconButton()
menuButton.pulseColor = MaterialColor.white
menuButton.tintColor = MaterialColor.white
menuButton.setImage(UIImage(named:"back.png"), forState: .Normal)
menuButton.setImage(UIImage(named:"back.png"), forState: .Highlighted)
and this is the output:-

If you could tell me how I can use my own image instead of the library ones that would be great too!
I got your sample project to work by following these steps:-
Open the Material workspace in the Examples directory.
Compile the Material.framework project by choosing the scheme in the Xcode navigation bar. The device needs to be on Generic Device, or an actual iOS device, not simulator.
Click on the project you want to run in the examples directory.
Open the 'General' page in the project inspector.
Go to Embedded Binaries, and add the Material.framework binary.
Choose the project scheme in the top navigation bar that you want to run.
Press run.
For the actual project, do I need to do the same? I'm using CocoaPods. This is how my Podfile Looks
source 'https://github.com/CocoaPods/Specs.git'
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'mysky' do
pod 'Material', '~> 1.42'
end
target 'myskyTests' do
end
Also, please do let me know how to use my own images without the scaling issue
Note: I believe this is a general problem with the library not being able to render it's images and not just on the toolbar
Ok so if u are importing an external image here it should be 24x24
The issue you are reporting is not reproducible as we are and to view the icons there, share the sample you are using @PuneetKohli ?
@puneetkohli it is actually a CoocoaPods issue not understanding bundles well. That said, there are setups where things get messed up by storyboards with CoocoaPods and bundled content. The best approach here, is to send your sample to us, and we can diagnose. Please send to [email protected]. All the best :)
Hi @PuneetKohli
Is the problem solved? I have same issue. Here is my Podfile.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Material', '~> 1.0'
@iomerbakirci The issue i with cocoa pods so we suggest you to try following this tutorial Material Workspace if the problem persists please send our project at [email protected]
@iomerbakirci @PuneetKohli Hey... so I worked with your project and there seems to be an issue, as you specified. So there are two easy solutions: follow the Workspace Setup, which works with the CocoaPods workspace, or two, copy the Assets catalog from the Material framework into your project and search for the icons as so:
menuButton.setImage(UIImage(named: "cm_arrow_back_white"), forState: .Normal)
I have seen this issue work and not work many times. I believe CocoaPods handles bundles poorly, as there is nothing special about how Material organizes the Assets catalog.
I hope this helps and please feel free to reach out if you need any help.