Code Rain, or Digital Rain, is a famous visual effect from the Matrix movie trilogy. This view is a Swift implementation to it.
JSMatrixCodeRainView works on iOS8.0+(Tested) with ARC projects.
It uses the following frameworks:
- Foundation.framework
- UIKit.framework
- QuartzCore.framework
-
Modify your Info.plist;
The view used a customized font called 'Matrix Code NFI', to include that you need to add an entry,
Fonts provided by application
in theInfo.plist
. -
Copy
JSMatrixCodeRainView.swift
and the font file to your project; -
Configure if needed. There are three configurable variables now:
speed
, aCGFloat
value, the unit is insecond
, controls the speed of the animation. The value is the time interval of the characters coming from above.
For example, the default value is 0.15, which means in every 0.15s, a new character will drop (if reasonable).newTrackComingLap
, also aCGFloat
value, the unit issecond
, generally control the number of the tracks.
Again as an example, the default value is 0.4, means that in every 0.4s, a new track will drop down from the available space (that is, there's no others occupying.)tracksSpacing
, anInt
value, the unit ischaracter
, control the spacing of two tracks.
The default value is 5, therefore after a track is completely shown, there will be no other track from the same line unless 5 characters passed.
You can manually set it or set it via Interface Builder, as shown below:
-
That's all. Use it as any
UIView
s.
The font Matrix Code NFI
is from Norfok® Inc. software.
This code is distributed under the terms and conditions of the MIT license.
Also check the Matrix Code NFI
license if you're intended to commercial use.