zipme / rqshinelabel Goto Github PK
View Code? Open in Web Editor NEWSecret app like text animation
License: MIT License
Secret app like text animation
License: MIT License
For some reason, in Landscape, the coordinates totally freak out. I can change it to (5, 5, 250, 500) and it will not appear where it should be, in fact, I can't even use negatives to get it to appear at the top. I'm attaching it to the subview of my overall view, so 0,0, should signify the top left, but no go. Still working on this, but I'm pretty sure it has to do with my app working in landscape and not portrait.
Edit: Just realized I complained without leaving anything positive: big thanks to the author for the control, it's super beautiful and exactly what I need for my project, I just have to get it to work :-)
Hello!
I love it, but I cannot use it by creating an UILabel with custom class RQShineLabel through an IBOutlet in my storyboard.
The only thing missing to work is to add the "awakeFromNib" function in the RQShineLabel implementation. I have added it and called [self commonInit] and it works perfectly, so if you wish, i think you can add that to be able to use it from storyboards or nibs :)
PS: I am someway new at developing with iOS, so my "solution" may not be the 'perfect one' (hell, it can be a total mess! :P) . I just know that an IBOutlet called from storyboards/nibs calls the "awakeFromNib" function, so I changed it in your code so I can use it 'not' programatically :)
Thanks for the code!!!
can it be done with a uitextview?
I need to repeat the shine when the user touch on a UIButton. There is a way to reset the label to the initial state and then call the shine again?
Hi, I'd like to ask you how can I use this component with Swift? I'm not familiar with Objective C at all.
Especially lines:
self.shineLabel = [[RQShineLabel alloc] initWithFrame:CGRectMake(16, 16, 298, 300)];
and
[self.shineLabel shine];
Thank you
Edit:
Sorry with stupid question. Here is my solution:
Ad.1 self.shineLabel = RQShineLabel(frame: CGRectMake(16, 16, 298, 300))
Ad.2 self.shineLabel.shine()
If you set the UILabel alignment to center or right with multiline text (2+ more lines) the first line is aligned to the left while the rest of the lines are aligned center or right.
There is a property fadeoutDuration but doesn't have any impact on animation and it is not used anywhere in code. As a workaround I'm using shineDuration instead.
When the label is loading all of the text is compressed onto one line whilst animating, will then appear normal after animation completed.
I have tried to change the _fadeoutDuration
from 2.5s to another value, but it doesn't work
I find that you made mistake in this function,
- (void)startAnimationWithDuration:(CFTimeInterval)duration
{
self.beginTime = CACurrentMediaTime();
self.endTime = self.beginTime + self.shineDuration;
self.displaylink.paused = NO;
}
Maybe you should add duration
rather than self.shineDuration
I fixed it but another bug happen, and I fixed it finally with inserting these code below into your updateAttributedString
if (now > self.endTime) {
self.displaylink.paused = YES;
for (NSUInteger i = 0; i < self.attributedString.length; i++) {
self.characterAnimationDelays[i] = @(arc4random_uniform(self.fadeoutDuration / 2 * 100) / 100.0);
CGFloat remain = self.fadeoutDuration - [self.characterAnimationDelays[i] floatValue];
self.characterAnimationDurations[i] = @(arc4random_uniform(remain * 100) / 100.0);
}
if (self.completion) {
self.completion();
}
You use self.shineDuration
in setAttributedText
, it will affect the fadeoutAnimation, I add those code to update characterAnimationDurations
to get the right fadeoutAnimation. Need pull request? Hope you can understand my Chiglish :๏ผ
I've been having trouble getting this to work with a black/dark colored text. I know RQShineLabel defaults to using a white text color, but does it currently support different color texts? If not has anyone forked this to support that?
Thanks.
https://github.com/zipme/RQShineLabel/blob/master/Classes/RQShineLabel.m#L149
I guess it's
self.endTime = self.beginTime + duration;
instead of
self.endTime = self.beginTime + self.shineDuration;
Hello i want repeat this animation while calling an API. But it's not happening. Please suggest, how to handle it
I want to create the animation that the label shines first, then followed by fading out the text and then switching the image in an imageview and after the completion of switching image I want to shine some other text, and repeat this process forever. Yet I do not know why the completion block for fadeout is not called.
Here is some of my code:
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()
}
}
}
CocoaPods
and Carthage
are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
when you add this label in the controller, and push out then push back, loop this operation, the memory will rise up , what I should do at this time?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.