• This repository has been archived on 21/Jun/2023
  • Stars
    star
    263
  • Rank 155,624 (Top 4 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AmazeKit is a library for rendering beautiful images in your iOS app.

AmazeKit

AmazeKit is an image rendering library for iOS. Its goal is to retain the performance of using .png-formatted images in UIKit classes, while avoiding the chore of creating these images in Photoshop, as well as the extra download size of bundling the images in the app. Images are rendered according to a collection of “image effects,” ranging from a simple gradient or corner radius to blurs, masks, and inner shadows. AmazeKit also offers convenient UIKit support, automatically using the correct images as your controls change size. Retina displays are supported automatically, and AmazeKit aggressively caches rendered images to maintain optimal performance levels.

Getting Started

The recommended way to get AmazeKit is to use CocoaPods.

TODO: Add instructions for bundling AmazeKit, using a static library, Xcode subproject, and as a Git submodule.

Examples

The best way to see how AmazeKit works is to see it in action. Let’s look at a couple of common use cases and see what they produce:

Rendering an Individual Image

The following code sets up an AKImageCoordinator. This class is responsible for rendering an image into a UIImageView, automatically rendering it at the appropriate size:

// Noise Effect
AKNoiseImageEffect *noiseEffect =
[[AKNoiseImageEffect alloc] initWithAlpha:0.05f
                                blendMode:kCGBlendModeMultiply
                                noiseType:AKNoiseTypeBlackAndWhite];

// Gradient Effect
UIColor *beginColor = [UIColor colorWithRed:144.0f / 255.0f
                                      green:144.0f / 255.0f
                                       blue:144.0f / 255.0f
                                      alpha:1.0f];

UIColor *endColor = [UIColor colorWithRed:103.0f / 255.0f
                                    green:103.0f / 255.0f
                                     blue:103.0f / 255.0f
                                    alpha:1.0f];

AKGradientImageEffect *gradientEffect =
[[AKGradientImageEffect alloc] initWithAlpha:1.0f
                                   blendMode:kCGBlendModeMultiply
                                      colors:@[beginColor, endColor]
                                   direction:AKGradientDirectionVertical
                                   locations:nil];

// Color Effect
AKColorImageEffect *colorEffect =
[[AKColorImageEffect alloc] initWithAlpha:1.0f
                                blendMode:kCGBlendModeColor
                                    color:[UIColor blueColor]];


// Create the image renderer
AKImageRenderer *imageRenderer = [[AKImageRenderer alloc] init];

[imageRenderer setImageEffects:@[
 noiseEffect,
 gradientEffect,
 colorEffect
 ]];

AKImageCoordinator *imageCoordinator = [[AKImageCoordinator alloc] init];
[imageCoordinator setImageRenderer:imageRenderer];

[imageCoordinator addImageView:myImageView];

This produces the following image output (for an image view with a size of 250 x 100 on a Retina display):

Example Image 1

Rendering Button Images

The AKButtonImageCoordinator class is like the AKImageCoordinator class, but it takes two image renderers instead of one. The “off” image renderer is used for the button’s normal control state, and the “on” image renderer is used for the button’s highlighted control state. The AKButtonImageCoordinator takes care of rendering background images for your button and automatically renders them to the correct size. Here’s an example:

// The butons will have a noise effect, rounded corners, and a gradient in
// common.
AKNoiseImageEffect *noiseEffect =
[[AKNoiseImageEffect alloc] initWithAlpha:0.05f
                                blendMode:kCGBlendModeMultiply
                                noiseType:AKNoiseTypeBlackAndWhite];

UIColor *topColor = [UIColor colorWithRed:144.0f / 255.0f
                                    green:144.0f / 255.0f
                                     blue:144.0f / 255.0f
                                    alpha:1.0f];

UIColor *bottomColor = [UIColor colorWithRed:103.0f / 255.0f
                                       green:103.0f / 255.0f
                                        blue:103.0f / 255.0f
                                       alpha:1.0f];

AKGradientImageEffect *gradientImageEffect =
[[AKGradientImageEffect alloc] initWithAlpha:1.0f
                                   blendMode:kCGBlendModeMultiply
                                      colors:@[topColor, bottomColor]
                                   direction:AKGradientDirectionVertical
                                   locations:nil];

AKCornerRadii cornerRadii = AKCornerRadiiMake(4.0f, 4.0f, 4.0f, 4.0f);

AKCornerRadiusImageEffect *cornerRadiusEffect =
[[AKCornerRadiusImageEffect alloc] initWithAlpha:1.0f
                                       blendMode:kCGBlendModeNormal
                                     cornerRadii:cornerRadii];

// The “off” state is blue, the “on” state is red.
AKColorImageEffect *onColorEffect =
[[AKColorImageEffect alloc] initWithAlpha:1.0f
                                blendMode:kCGBlendModeColor
                                    color:[UIColor redColor]];

AKColorImageEffect *offColorEffect =
[[AKColorImageEffect alloc] initWithAlpha:1.0f
                                blendMode:kCGBlendModeColor
                                    color:[UIColor blueColor]];

// We create two image renderers, one for each state
AKImageRenderer *offImageRenderer = [[AKImageRenderer alloc] init];
AKImageRenderer *onImageRenderer = [[AKImageRenderer alloc] init];

// And we assign the image effects for each.
[offImageRenderer setImageEffects:@[
 noiseEffect,
 gradientImageEffect,
 offColorEffect,
 cornerRadiusEffect
 ]];

[onImageRenderer setImageEffects:@[
 noiseEffect,
 gradientImageEffect,
 onColorEffect,
 cornerRadiusEffect
 ]];

// Next we create the button image coordinator and assign the image
// renderers to it
AKButtonImageCoordinator *buttonImageCooordinator =
[[AKButtonImageCoordinator alloc] init];

[buttonImageCooordinator setOffImageRenderer:offImageRenderer];
[buttonImageCooordinator setOnImageRenderer:onImageRenderer];

// Finally, we add a button.
[buttonImageCooordinator addButton:myButton];

This produces the following image output (for a button that’s 150 x 44 on a Retina display):

Off: Example Image 2 (Off) On: Example Image 2 (On)

The bin Directory

In the bin directory are two scripts: gen_docs.sh and publish_docs.sh. These scripts are meant for me to run as a convenience to publish the appledoc docs. Use caution when running them.

Build Status

Build Status

AmazeKit was developed in Detroit by Jeff Kelley at Detroit Labs.

More Repositories

1

SheetPresentation

A UIPresentationController and attendant clases for iOS to present a view controller pinned to the bottom of the screen like an action sheet.
Swift
36
star
2

katalon-mobile-util

Library of utilities to make mobile UI testing in Katalon Studio easier
Java
23
star
3

IRLSize

A library for determining the actual physical size of pixels on an iOS device.
Objective-C
19
star
4

swift-codable-examples

Swift Codable Examples
Swift
18
star
5

Orchard

Device identification in Swift and Objective-C for iOS, watchOS, and tvOS.
Objective-C
17
star
6

UE-iOS-Hybrid

Example project for a Hybrid iOS and Unreal Engine application
C
12
star
7

NerdNite

Nerd Nite Android project
Java
9
star
8

hubot-badger

The Hubot Badger
CoffeeScript
8
star
9

dl-coaching-unix-fundamentals

Detroit Labs Developer Coaching / Unix Fundamentals
Shell
7
star
10

UE-iOS-Hybrid-Framework

Example Framework project for a Hybrid iOS and Unreal Engine application
Objective-C
7
star
11

fastlane-template

Detroit Labs Fastlane Template
Ruby
5
star
12

dlr-waterfalllayout

A Waterfall Collection View Layout
Objective-C
5
star
13

DLVersion

Class for working with iOS app versions
Objective-C
4
star
14

ci-scripts

Sample scripts for CI
Shell
4
star
15

safe-xcode-select

A wrapper for xcode-select that can be called without sudo.
Objective-C
4
star
16

dl-coaching-comp-sci-fundamentals

Detroit Labs Developer Coaching / Computer Science Fundamentals
HTML
3
star
17

labslibs

Java
2
star
18

Playground

Experiments and Try-Me-Outs
2
star
19

YooToob

A sample app to download a YouTube playlist.
Objective-C
2
star
20

dlr-checkpoint-navigation-controller-ios

Detroit Labs Recipes - Checkpoint Navigation Controller
Objective-C
2
star
21

tapkulibrary

Fork of Devin Ross's Tapku Library. Modified for use in the Stryker App.
Objective-C
2
star
22

react-lifting-state

A demo app for lifting state using only React, and broken into 5 steps.
TypeScript
1
star
23

labs-cloud-actions

Shell
1
star
24

tslint-config

Shared TSLint configuration used in Detroit Labs' TypeScript projects
1
star
25

dlr-app-store-ratings-ios

Detroit Labs Recipes - App Store Ratings
Objective-C
1
star