Code Monkey home page Code Monkey logo

cdfinitialsavatar's Introduction

CDFInitialsAvatar

Simple to use initials avatar generator for iOS. Highly customizable, but with sane defaults. Works great as a avatar placeholder till network image is loaded or as an actual image if user has no avatar at all.

Sample Image

Usage

Defaults mimic look of Apple's own implementation of initial avatars, found in Contact.app and Messages.app on iPhone or OS X. Usage can be as simple those two lines:

CDFInitialsAvatar *initialsAvatar = [[CDFInitialsAvatar alloc] initWithRect: imageView.bounds fullName:@"Toto Tvalavadze"];
imageView.image = initialsAvatar.imageRepresentation; // actual drawing happens here

Further Customizations

You can change backgroundColor, initialsFont and initialsColor. This should cover everything. For details, refer to header file. It's well documented.

Example project also contains usage samples.

What About Circle Avatars?

I believe generator should be responsible for content only, thus in case you want to mask content with circle (or pretty much any shape), please consider mask layer of your UIImageView.

See example project to view actual sample.

Caching

CDFInitialsAvatar does not cache images it generates. Consider implementing your choice of image caching strategy when using it inside a cell views or in similar cases. In short, treat imageView.image = initialsAvatar.imageRepresentation as a very expensive call (which it is).

Rendering

Actual drawing happens when imageRepresentation is called and obviously, is expensive. Consider using it wisely and wrapping it with your choice of caching strategy if needed.

No drawing or/and calculations happen on initWith....

License

MIT. Included in source files.

cdfinitialsavatar's People

Contributors

samacs avatar spnkr avatar totocaster 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  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  avatar  avatar

cdfinitialsavatar's Issues

CGContextRestoreGState

: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

No image was shown.

Cocoapods?

Any plans on adding this to Cocoapods?

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.