Git Product home page Git Product logo

brpdfimage's Introduction

BRPDFImage

The Little UIImage Class That Could (draw vector art)

As an iOS developer, have you ever thought any of the following:

  • I wish there was a way use vector icons (instead of bitmap ones)!
  • I'm tired of making two PNG icons for every image, to support retina images!
  • I don't want to make @4x icons when the new Eagle Eye Retina Display comes out!
  • I have all these icons created in [Illustrator, Inkscape, ...] and I'm annoyed that I have to re-render them as PNG files every time I make a change!
  • Why is it raining right now?

If you have, then BRPDFImage is here to help you, and wash away those rainy day blues. BRPDFImage is a very small extension of UIImage that allows you to use PDF artwork anywhere a UIImage is needed. The PDF format can be thought of as just another vector art file format, and in fact any vector art editing program worth a lick will support saving PDF files.

Supported OS Versions

BRPDFImage supports iOS 5+. Yep, our old friend the iPad 1 is still supported. Keep on goin' on, little iPad 1.

Example use

Here is an example of how simple it is to use BRPDFImage:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"sunshine" withExtension:@"pdf"];
UIColor *tintColor = [UIApplication sharedApplication].keyWindow.tintColor;
UIImage *img = [[BRPDFImage alloc] initWithURL:url maximumSize:CGSizeMake(32,32) tintColor:tintColor];

This creates a UIImage from sunshine.pdf in the application's main bundle. The image will be treated as a mask and opaque pixels will be tinted the main window's tint color. You can pass a nil tint color to not give it the tinted treatment.

How it works

BRPDFImage simply renders the PDF resource into a bitmap image when you initialize it, which is why you must pass in a desired CGSize (or maximum size) when doing so. From that point on, you basically have a normal UIImage and can treat it as such.

PDF rendering on iOS is pretty fast, but if you're using a lot of BRPDFImage's in a UITableView or UICollectionView you might want to cache the instances for better performance. The Demo App included in the project does just that (see below).

Project Integration

Just copy BRPDFImage.h and BRPDFImage.m into your project. These are located in the BRPDFImage/BRPDFImage directory. You will need to add the CoreGraphics.framework to your build target, if it's not already included. Easy!

Demo App

The repository also inclues a small iPhone/iPad app that runs on iOS 5.1.1 or later. It will render a UITableView (iOS < 6) or a UICollectionView (iOS >= 6) full of some randomly tinted PDF icons. The icons come courtesy of Font Awesome (thanks, Dave, you're awesome).

Demo App

brpdfimage's People

Contributors

msqr 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.