MMScalableVectorView 0.1.0

MMScalableVectorView 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total1,477
Week0
Month0

Installs

Apps17
Test Targets3
powered by Segment

GitHub

Stars108
Watchers8
Forks8
Issues1
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 110



  • By
  • Mike Maxwell

Turns static PaintCode or Qwarkee code into a UIView that honors its contentMode property.

Before
After

Installation

Manually

Just import MMScalableVectorView.m & .h into your project directly.

Requirements

  • iOS 4.x or higher
  • CoreGraphics framework
  • ARC

Usage

Using MMScalableVectorView Directly

  1. Use - (id)initWithFrame:(CGRect)frame drawingBlock:(void (^)(void))drawingBlock originalSize:(CGSize)originalSize to create a new instance of MMScalableVectorView, providing the vector drawing block and original size.
  2. Set the object's contentMode as desired.
  3. Add the view to a view hierarchy or draw it manually using - (void)drawInFrame:(CGRect)frame.

Subclassing

  1. Create a new class to represent the graphic, and make sure it inherits from MMScalableVectorView.
  2. Implement the following methods:
    1. Paste the Qwarkee/PaintCode drawing code into drawInCurrentContext
    2. Implement originalSize to return a CGSize structure for the native size of the vector graphic.
  3. Use the newly created class as a normal UIView, setting the contentMode property as desired before the view is drawn. This can be done in Interface Builder or programatically.

Demo

Run pod install inside the Demo folder, then load the Demo workspace & run!

Future Improvements

  1. UIView category with a block-based initializer for one-step creation of vector-backed UIViews.
  2. Improving drawing when UIView’s transform property is used (?)
  3. Unit tests!