RQShineLabel
RQShineLabel copied to clipboard
Here is a working SWIFT example: Auto change text with timer
Just wanted to put it out there in case anyone needs it. Here is a swift controller, and changes the text itself with a timer.
// // IntroViewController.swift // // Created by Jason wang on 8/16/17. //
import Foundation import UIKit import RQShineLabel import Parse
class IntroViewController: UIViewController { var shineLabel = RQShineLabel() var timer = Timer() var textArray = ["111", "222", "333"] var currentCount = 0
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.shineLabel.shine()
}
var background1 = UIImageView()
var background2 = UIImageView()
override func viewDidLoad() {
super.viewDidLoad()
background1 = UIImageView(image: UIImage(named: "IntroBackground1")!)
background1.contentMode = .scaleAspectFill
background1.frame = self.view.bounds
self.view.addSubview(background1)
background2 = UIImageView(image: UIImage(named: "IntroBackground2")!)
background2.contentMode = .scaleAspectFill
background2.frame = self.view.bounds
background2.alpha = 0
self.view.addSubview(background2)
self.shineLabel = RQShineLabel(frame: CGRect(x: 16, y: 16, width: 298, height: 300))
self.shineLabel.numberOfLines = 0;
self.shineLabel.text = "Welcome to my app"
self.shineLabel.backgroundColor = UIColor.clear
self.shineLabel.font = UIFont(name: "HelveticaNeue-Light", size: 18.0)
self.shineLabel.center = self.view.center;
self.view.addSubview(self.shineLabel)
scheduledTimerWithTimeInterval()
self.view.bringSubview(toFront: self.logo)
self.view.bringSubview(toFront: self.loginView)
}
func scheduledTimerWithTimeInterval(){
// Scheduling timer to Call the function "updateCounting" with the interval of 1 seconds
timer = Timer.scheduledTimer(timeInterval: 8, target: self, selector: #selector(self.updateCounting), userInfo: nil, repeats: true)
}
func updateCounting(){
if (self.shineLabel.isVisible) {
self.shineLabel.fadeOut(completion: {
let textIndex = self.currentCount % self.textArray.count
let text = self.textArray[textIndex]
self.shineLabel.text = text
self.currentCount += 1
UIView.animate(withDuration: 2.5, animations: {
if (self.background1.alpha > 0.1) {
self.background1.alpha = 0;
self.background2.alpha = 1;
}
else {
self.background1.alpha = 1;
self.background2.alpha = 0;
}
})
self.shineLabel.shine()
})
} else {
self.shineLabel.shine()
}
}
}
Hi there, could this be used with storyboard instead programmatic Label?
RQShineLabel
inherits from UILabel
. Just add it as a label in IB and set the class to RQShineLabel
.