Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sodales sollicitudin suscipit. Maecenas hendrerit arcu at lacus vestibulum facilisis. Duis sodales diam vel felis fermentum luctus. Ut convallis, odio in placerat ullamcorper, massa nunc fermentum odio, id consectetur lorem mi vel enim.
Description
MPTextReveal is a powerful text animation library for iOS that allows you to easily create stunning reveal effects on your text. This library provides a wide range of customizable options, allowing you to create unique and eye-catching animations.
Installation
To install MPTextReveal, you can use CocoaPods. Simply add the following line to your Podfile:
pod 'MPTextReveal'
Usage
Basic Usage
Start by importing the MPTextReveal library:
import MPTextReveal
Next, create an instance of RevealView:
let revealView = RevealView(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
revealView.text = "Your Text"
Finally, add the revealView to your view hierarchy:
view.addSubview(revealView)
Customization
MPTextReveal comes with various customizable options:
Color
To change the color of the revealed text, use the revealText(color:)
method:
revealView.revealText(color: .blue)
Duration
You can set the duration of the reveal animation using the revealDuration
property:
revealView.revealDuration = 2.0
Font
To customize the font of the text, use the textFont
property:
revealView.textFont = UIFont.systemFont(ofSize: 20)
Reveal Direction
You can set the reveal direction using the revealDirection
property:
revealView.revealDirection = .rightToLeft
Animation Type
MPTextReveal provides different animation types:
- Linear:
revealView.animationType = .linear
- Fade:
revealView.animationType = .fade
- Expand:
revealView.animationType = .expand
- Slide:
revealView.animationType = .slide
Delegate
If you need to be notified when the reveal animation finishes, you can set the delegate:
revealView.delegate = self
Implement the RevealViewDelegate
protocol to receive the callback:
extension YourViewController: RevealViewDelegate {
func revealAnimationDidFinish() {
// Animation finished
}
}
Examples
MPTextReveal can be used in various scenarios. Here are some examples:
Example 1: Reveal Animation
In this example, we’ll animate the reveal of a text:
// Create an instance of RevealView
let revealView = RevealView(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
revealView.text = "Hello World"
// Customize the reveal animation
revealView.revealDuration = 2.0
// Add revealView to the view hierarchy
view.addSubview(revealView)
Example 2: Customization
MPTextReveal allows for extensive customization. Here’s an example of changing the text color and font:
// Create an instance of RevealView
let revealView = RevealView(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
revealView.text = "Customized Text"
// Customize the text color
revealView.revealText(color: .red)
// Customize the text font
revealView.textFont = UIFont.boldSystemFont(ofSize: 24)
// Add revealView to the view hierarchy
view.addSubview(revealView)
Conclusion
MPTextReveal is a feature-rich text animation library for iOS, providing an easy and flexible way to create impressive text reveal effects. Whether you need a simple reveal animation or full customization options, MPTextReveal has got you covered.