How to add slide to unlock effect in UITextView or UILabel?

I have a lot of text and you want to add a slide-like effect to unlock one of the latest iOS, and it will go from top to bottom with text moving from bottom to top.

+6
source share
3 answers

I suggest you use the Grant Pauls Shimmer control because it does just that.

https://github.com/facebook/Shimmer

example

+6
source

Update with quick flickering mark, view, etc.

import UIKit import QuartzCore class ViewController: UIViewController { @IBOutlet var testLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() self.testLabel.startShimmering() } } extension UIView { func startShimmering() { // let light = UIColor.init(white: 0, alpha: 0.1).cgColor let light = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor let dark = UIColor.black.cgColor let gradient: CAGradientLayer = CAGradientLayer() gradient.colors = [dark, light, dark] gradient.frame = CGRect(x: -self.bounds.size.width, y: 0, width: 3*self.bounds.size.width, height: self.bounds.size.height) gradient.startPoint = CGPoint(x: 0.0, y: 0.5) gradient.endPoint = CGPoint(x: 1.0, y: 0.525) gradient.locations = [0.4, 0.5, 0.6] self.layer.mask = gradient let animation: CABasicAnimation = CABasicAnimation(keyPath: "locations") animation.fromValue = [0.0, 0.1, 0.2] animation.toValue = [0.8, 0.9, 1.0] animation.duration = 1.5 animation.repeatCount = HUGE gradient.add(animation, forKey: "shimmer") } func stopShimmering() { self.layer.mask = nil } } 
+2
source

Check out this link .. hope this helps

https://github.com/iosdeveloper/SlideToCancel

+1
source

All Articles