Coder Social home page Coder Social 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

neilkennedy avatar mbrit avatar mikescott8 avatar jeffbmiller avatar

Watchers

James Cloos avatar

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.