Reputation: 13199
I am trying to use Material Icons
library on my swift
application on Xcode
but I cannot make that the library will be detected by the project.
The steps that I have followed:
Am I doing something in the wrong way?
Thanks in advance!
Upvotes: 3
Views: 3403
Reputation: 13199
As @EricAya pointed I was following the wrong steps. I saw that there were steps to use Material icons
for iOS but as it says in the documentation:
Material icons also work well within iOS apps. In both the material icons library and git repository, these icons are packaged up in Xcode imagesets which will work easily with Xcode Asset Catalogs (xcassets).
I guessed that it could also be installed with git repository but I could not get it. Finally I used the following steps:
Go to the official webpage of Material icons
and click on the icon that you would like to use.
You will see on the right corner of the webpage two options to download the icon (SVG or PNG). I have chosen PNG.
Unzip the .zip package.
Open ios
folder and drag the .imageset
folder to your .xcassets
file in your project of Xcode.
You can create both an imageView
or button
to set it and use the following code to create the image:
UIImage(named:"ic_close")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
To set it to your UIImageView you can use yourImage.image
and for your button yourButton.setImage()
.
Do not forget to change the tint
property of your imageView
or button
. I spent some hours thinking that it was not working and the problem was that the tint property was white (sometimes simpler things make waste your time easily).
Upvotes: 8