From the prolifically open sourcing Matt Legend Gemmell, here’s MGImageUtilities, some useful UIImage categories for your iPhone development:
UIImage+ProportionalFill
This category lets you resize an arbitrary image to fit into a specified physical size, using one of four resizing methods:
- Scale: scales the image proportionally to fit entirely into the required size, like UIViewContentModeScaleAspectFit.
- Crop: scales the image proportionally to completely fill the required size, cropping towards its center. This is the most useful method, and works like UIViewContentModeScaleAspectFill.
- Start: as for Crop, but crops towards the “start” of the image (the top or left, depending on relative aspect ratios).
- End: as for Crop, but crops towards the “end” of the image (the bottom or right, depending on relative aspect ratios).
UIImage+Tint
This category takes an image (presumably flat and solid-coloured, like a toolbar icon), and fills its non-transparent pixels with a given colour. You can optionally also specify a fractional opacity at which to composite the original image over the colour-filled region, to give a tinting effect.
Source is on github, enjoy!
12
JUL
JUL
0
Share