Giter Club home page Giter Club logo

reflection-swift's Introduction

Reflection

Description

This sample shows how to implement a "reflection" special effect on a given UIImageView most commonly seen in iTunes and iPod player apps. It allows the rendering effect with "dynamic" input values for 1) reflection height and 2) translucency level. These values can be plugged into the factory methods provided by this sample to achieve a desired affect.

This sample implements a UIImageView and programmatically builds a "reflection" image view below it using CoreGraphics. Essentially it builds the reflection using a combination of CGContextRef, CGImageRef and CALayer to do the desired rendering.

The main entry method in creating the reflected image is -

  • (UIImage *)reflectedImage:(UIImageView *)fromImage withHeight:(NSUInteger)height;

So you would assign the image to a UIImageView and set its alpha value like so -

reflectionView.image = [self reflectedImage:imageView withHeight:reflectionHeight]; reflectionView.alpha = 0.50;

Build Requirements

iOS 9.0 SDK or later

Runtime Requirements

iOS 7.0 or later

Using the Sample

Build and run the sample using Xcode. To run in the simulator, set the Active SDK to Simulator. To run on a device, set the Active SDK to the appropriate Device setting.

When launched, use the two sliders at the bottom to adjust the size and translucency or alpha values of the reflection. These two values range from 0.0 to 1.0. The slider values are displayed to the right. You can use these values by plugging them into the methods that generate the desired reflection effect.

Copyright (C) 2008-2015 Apple Inc. All rights reserved.

reflection-swift's People

Contributors

ooper-shlab avatar

Stargazers

 avatar

Watchers

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