Git Product home page Git Product logo

fontawesome.xamarin's Introduction

#FontAwesome.Xamarin

This is a simple library to help when using FontAwesome with Xamarin.iOS. All v4.0.3 icons from the cheatsheet are included.

##Getting started

  • Add dist/FontAwesome.Xamarin.dll to your project
  • Add dist/FontAwesome.ttf to the Resources directory of your project
    • Set Build Action to "BundleResource"
    • Set Copy to output directory to "Always Copy"
  • Open Info.plist
    • Click on the Source tab
    • Add a new property and select "Fonts provided by application" from the dropdown list
    • Add a new item to the array called FontAwesome.ttf

##Using it ###FontAwesome.cs Once the library and font have been added, using FontAwesome is very simple. There is one static method .Font(int size) that returns the UIFont class with the specified size. Each icon is listed as a static method. The CSS class of fa-lock would become FontAwesome.FALock.

using FontAwesomeXamarin;

UILabel lockLabel = new UILabel (new RectangleF (0, 30, 320, 100)) {
  Font = FontAwesome.Font(100), //100 is the font size we want to use
  Text = FontAwesome.FALock, //Here we're using the lock icon "fa-lock"
  TextColor = UIColor.White,
  TextAlignment = UITextAlignment.Center
};

Icon in a UILabel

Because FontAwesome is a font based icon library we can set the text color and size in the same way we would for any other regular font.

###FABarButtonItem.cs This will create a UIBarButtonItem with a FontAwesome icon that can be used in a UINavigationBar. Internally it uses a UIButton for the font and click event and adds it as the CustomView of the UIBarButtonItem.

NavigationItem.RightBarButtonItem = new FABarButtonItem (FontAwesome.FATrashO, UIColor.White, delegate {
  //Click event handler
});

Navigation Bar Icon

NavigationItem.RightBarButtonItem = new FABarButtonItem (FontAwesome.FAGithub, "Github", UIColor.White, delegate {
  //Click event handler
});

Navigation Bar Icon with Title

###FAButton.cs This is an extension of UIButton. It simply sets the font to FontAwesome.Font() and contains easy access methods to the Icon and IconSize.

var deleteBtn = new FAButton (FontAwesome.FATrashO, UIColor.White, 20) {
  Frame = new RectangleF (0 , 0, 25, 25)
};

fontawesome.xamarin's People

Contributors

jeffbmiller avatar mbrit avatar mikescott8 avatar neilkennedy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fontawesome.xamarin's Issues

Reference issue with monotouch.dll

When I try to create a demo like you provide I get the following error when trying to build the project:

"error MT0034: Cannot reference 'monotouch.dll' in a Xamarin.iOS project - it is implicitly referenced by 'FontAwesome.Xamarin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'."

I replaced the line

label.Font = FontAwesome.Font(100)

with

label.Font = UIFont.FromName("FontAwesome", 30);

which is pretty much the same as FontAwesome is doing of course ;-)
Issue is when using the second line there is no build issue BUT when using the first line I get the build error. Seems that that the nuget package references an other monotouch assembly as the normal project.

I installed FontAwesome from nugetPackage as version 4.0.3.

Environment:
=== Visual Studio Community 2017 for Mac ===

Version 7.0.1 (build 24)
Runtime:
Mono 5.0.1.1 (2017-02/5077205) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 500010001

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: 10.10.0.36 (Visual Studio Community)
Hash: d2270eec
Branch: d15-2
Build date: 2017-05-22 16:30:53-0400

=== Xamarin.Mac ===

Version: 3.4.0.36 (Visual Studio Community)

=== Build Information ===

Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Thu Jun 15 17:36:27 PDT 2017
root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

Recompile for unified api?

Hi :-).

This looks really cool! However, I get the following error when trying to compile my project:

Error MT0034: Cannot include both 'monotouch.dll' and 'Xamarin.iOS.dll' in the same Xamarin.iOS project - 'Xamarin.iOS.dll' is referenced explicitly, while 'monotouch.dll' is referenced by 'FontAwesome.Xamarin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. (MT0034) (Reflect.Mobile.iOS)

Based on a little research I have learned that the build build of FontAwesome.Xamarin does not work with the unified iOS api. I tried recompiling the source but no luck so far. Any ideas?

Thanks for this project!

How do I make icons bold?

I am using couple of icons for button images
eg: icon2Button.SetTitle(FontAwesomeXamarin.FontAwesome.FAMapMarker, UIControlState.Normal);

I want to see these icons bold, change color. how do I make them?

This button does not have a title exception

I am trying to create a bar button item but it does not let me use the constructor where I do not give it a title. Whenever I try the code at the bottom, it tells me "This button does not have a title" so the view won't load. I tried the demo code in the documentation where the title is not explicitly set, also, and the same issue occurs.

NavigationItem.RightBarButtonItem = new FABarButtonItem(FontAwesome.FACog, UIColor.FromRGB(0,68,130), delegate { });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.