😄 你好~ 我是 Lex 汤,生活在上海,一个喜欢折腾各种技术,略懂一些 Swift 的中老年网友。
💬 2002 年开始工作,和技术、设计、产品相关的事都有做过,效力过的公司包括但不限于: 上海图书馆、土豆网、携程旅行网、现代传播周末画报iWeekly、平安壹钱包、nonda.co、米哈游。
📫 如果你想聊聊,可以给我发邮件,也可以 Telegram @lexrus 或 Twitter DM。
[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift.
License: MIT License
😄 你好~ 我是 Lex 汤,生活在上海,一个喜欢折腾各种技术,略懂一些 Swift 的中老年网友。
💬 2002 年开始工作,和技术、设计、产品相关的事都有做过,效力过的公司包括但不限于: 上海图书馆、土豆网、携程旅行网、现代传播周末画报iWeekly、平安壹钱包、nonda.co、米哈游。
📫 如果你想聊聊,可以给我发邮件,也可以 Telegram @lexrus 或 Twitter DM。
Maybe I can't use allValues
in LTMorphingEffect
. Should this be public?
@objc public enum LTMorphingEffect: Int, Printable {
...
static let allValues = ["Scale", "Evaporate", "Fall", "Pixelate", "Sparkle", "Burn", "Anvil"]
...
}
Nice piece of work!
I don't know if it is any interest to you, but you might wanna check out: https://github.com/MichMich/XMCircleType to see how I solved the kerning issue.
Keep up the good work!
Cheers,
Michael
Hi.
I tried this library, but happened build error.
Do you have a good idea for you to solve this problem?
Th error message is
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `X' in: -Xlinker
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
The Trace Message is
Libtool /Users/foo/Library/Developer/Xcode/DerivedData/Myproject-cslcvetdcomhqogpwoqocylrlfyq/Build/Products/Debug-iphonesimulator/libPods-LTMorphingLabel.a normal x86_64
cd /Users/foo/projects/privates/ios/Myproject/Pods
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -L/Users/foo/Library/Developer/Xcode/DerivedData/Myproject-cslcvetdcomhqogpwoqocylrlfyq/Build/Products/Debug-iphonesimulator -filelist /Users/foo/Library/Developer/Xcode/DerivedData/Myproject-cslcvetdcomhqogpwoqocylrlfyq/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-LTMorphingLabel.build/Objects-normal/x86_64/Pods-LTMorphingLabel.LinkFileList -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/foo/Library/Developer/Xcode/DerivedData/Myproject-cslcvetdcomhqogpwoqocylrlfyq/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-LTMorphingLabel.build/Objects-normal/x86_64/Pods_LTMorphingLabel.swiftmodule -framework Foundation -framework QuartzCore -framework UIKit -o /Users/foo/Library/Developer/Xcode/DerivedData/Myproject-cslcvetdcomhqogpwoqocylrlfyq/Build/Products/Debug-iphonesimulator/libPods-LTMorphingLabel.a
I installed by cocoapod.
My environment is as follows.
I am glad and enjoy tips for resolution.
Thank you.
Trying to set an LTMorphingLabel's attributedText
property currently causes an exception.
You probably have a better sense than I do about how hard adding support for attributed strings would be. I'm happy to dive in and help if it seems like it's low-hanging fruit. Thoughts?
Thanks!
Hi, great component so far! Having access to the following properties at design time would be very helpful and would cut down on boilerplate code to use this control:
public var morphingProgress: Float
public var morphingDuration: Float
public var morphingCharacterDelay: Float
public var morphingEffect: LTMorphingEffect
I believe we could implement this just by marking these properties as @IBInspectable
. Do you think there's anything else we'd have to do?
in LTMorphingLable.swift
let image = UIImage(named:"Sparkle").CGImage
When my view first loaded, I want to set some value for the label without effect animation.
How to make it?
self.upNumTxt.text = "init val"
Any suggestions ? Thx
I believe the current version doesn't support morphing for attributed text. Will this be a feature in the near future?
I would appriciate it if you tell me that your App is using LTMorphingLabel. Your shinny app may encourage me to make this lib better. And I'll list your App in the README.
Thanks.
I would like to learn how to apply other animations rather than default?
First of all, let me start by saying I love this project !
I have a project with 5-6 pods working on it, lately I've added this pod as well.
everything find when i'm adding label on storyboard and setting it to LTMorphingLabel.
The problem start when i'm trying to connect the label to code:
@IBOutlet private var label: LTMorphingLabel!
i'm getting this error, Use of undeclared type 'LTMorphingLabel'.
I've tried to import LTMorphingLabel class but it's not recognise as well, of course i've tried to close the project and clean it. did it happen to any of you ? is there any solution for this ? thank you so much. god bless.
having a CocoaTouch framework project would be more modular
After updating my project to Swift 2.2 in xcode 7.3 none of the following code showing 0 (zero) in the label.
myMorphingLabel.text = "0"
Or
let zeroValue = 0
myMorphingLabel.text = String(zeroValue)
myMorphingLabel.text = String(format: "\(zeroValue)")
But if I try with 1 or 0.0, it works.
Can please check this? Thanks.
I've found that setting strings longer than about 50 characters crawls to a halt. Sometimes crashes. A simple fix would be to just not animate if the length is greater than a certain number. I attempted to do this by modifying the setter for the text variable, pausing the display link and setting super.text to the value if it was above a threshold. This sometimes works, but I think I'm missing something, as I still get issues with performance. Advice appreciated. Would love to use this in the next rev of Slated if I can get it reliable.
i use "carthage update" to generate the framework file then i drag it into a single-view sample application and try to run it .After built, it crash and here is the output info
dyld: Library not loaded: @rpath/LTMorphingLabel.framework/LTMorphingLabel
Referenced from: /private/var/mobile/Containers/Bundle/Application/BC12B185-E20D-4B3A-9CEB-A9C1EDD18336/cccccc.app/cccccc
Reason: image not found
(lldb)
then i try add it into embedded binaries(before it the framework file was only be added in Linked Frameworks and Libraries )
after that it works. there is no more crash.
when storyboard is empty the sample application looks well.
then i add a label and a button like this:
import UIKit
import LTMorphingLabel
class ViewController: UIViewController {
@IBOutlet weak var label: LTMorphingLabel!
@IBAction func button(sender: AnyObject) {
label.text = "123"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
build it and run on my phone when i tap the button where is a EXC_BAD_ACCESS error
Is there something important i missed?
It's very cool label.
but I have a problem, Autoshrink(minimumFontScale) doesn't work. It shows fixed font size.
thx in advance, great work!
When my view is loaded, label is not visible. Only after certain action is taken to change label's text, label finally shows up.
Maybe there is something speciffic with configuration parameters that hides my label, I don't know. When I change my label's class to regular UILabel, it is visible, so there must be something with the LTMorphingLabel class itself.
Currently LTMorphingLabel does not render in a storyboard or xib
Hi,
Congrats for this label, it's very cool.
I have a problem. Everything displays properly centered on IOS 7 but is offsetted to the right on iOS 8 .
Do you have an idea?
Thanks
I knew CocoaPods is now compatible with Swift libs. And there is also another awesome option made by GitHub.
I'd like to support both.
Hi man!
Thanks for your job!
请问在OC 项目中如何设置效果?
.morphingEffect
在OC 中无法访问,且在Xcode自动生成的头文件中没有看到这个枚举选项。
多谢帮助。
I installed this by just dragging in the LTMorphingLabel folder (I firstly installed with cocoapods but it got messed up so I removed it).
I just followed the instructions under Usage and added a UILabel in storyboard and link it with @IBOutlet
and changed its class to LTMorphingLabel
@IBOutlet var lbl:LTMorphingLabel!
I get no error message or anything, it just breaks at the line where I either try to print out its text or when I try to set its text.
Im using xcode 6.2 and swift 1.1
A brand new and pure swift project, followed the instruction to add LTMorphingLabel. Build is fine, but when app is running, XCODE gives EXC_BAD_ACCESS. wondering why...
The resources folder(needed by Sparkle, Burn and Particle) doesn't seem to be accessible with use_frameworks in CocoaPods. If you drag the resources folder from the LTMorphingLabel pod into your project, it works ok. Not sure if there's a better approach. This should however be mentioned probably in the readme.
I've added the files manually to my project (just drag&drop, no framework created) since I have some issues with CocoaPods/Carthage.
I have also set the Interface Builder class object of the label to LTMorphingLabel. Did not add module since it's the current one.
Issue is the label is displayed with some default font instead of the one set in the storyboard. The text also has a big top offset and only the top half is displayed. The label does not have a height constraint in the storyboard, it just has top/bottom/trailing/leading spaces to superview set.
Thank you for the library, I really appreciate it. Job well done!
Edit: The text position is almost fixed if I call layoutSubviews()
on the label. The baseline is still a few pixels lower than the text using UILabel.
I know you have this in your notes, but wanted to let you know I think that's the one feature limiting this. That, or at least having auto shrink work. Really slick effects, though. I tried to do this myself, but failed miserably compared to this component. Considering this for the translation area of my keyboard translation app (grab a free copy here: http://tokn.co/ysqhsq9u).
...
Error in the LTMorphingLabel.swift file on installing Xcode 7.3.
On the line :
(if previousText != text && currentFrame++...) and ( if ++skipFramesCount > closure() {...)
There is the error '++ is deprecated and will be removed in Swift 3. I don't know how yet, but these lines will need an update. .
// MARK: - Animation extension
extension LTMorphingLabel {
func displayFrameTick() {
if displayLink.duration > 0.0 && totalFrames == 0 {
let frameRate = Float(displayLink.duration) / Float(displayLink.frameInterval)
totalFrames = Int(ceil(morphingDuration / frameRate))
let totalDelay = Float((text!).characters.count) * morphingCharacterDelay
totalDelayFrames = Int(ceil(totalDelay / frameRate))
}
if previousText != text && currentFrame++ < totalFrames + totalDelayFrames + 5 {
morphingProgress += 1.0 / Float(totalFrames)
if let closure = skipFramesClosures[
"\(morphingEffect.description)\(phaseSkipFrames)"
] {
if ++skipFramesCount > closure() {
skipFramesCount = 0
setNeedsDisplay()
}
} else {
setNeedsDisplay()
}
if let onProgress = delegate?.morphingOnProgress {
onProgress(self, morphingProgress)
}
} else {
displayLink.paused = true
delegate?.morphingDidComplete?(self)
}
}
I used CocoaPod to integrate LTMorphingLabel,
When I was using style
label.morphingEffect = .Anvil
I got fatal error: unexpectedly found nil while unwrapping an Optional value
This line caused crash
let image = UIImage(named:"Sparkle")!.CGImage
"Sparkle" image was not found. But I saw the image in Resource folder.
I'm noticing that when I change the height of the label, the vertical text alignment never changes.
The text appears to be vertically centered to the height it was originally created with, and then never adjusts after that when the frame height is changed.
Am I doing something wrong? Is there a way to trigger a relayout? I've already tried setNeedsLayout but that didn't seem to have any affect.
效果是非常炫的,我在iOS7 4s调试上发现非常占用CPU,比较卡顿,请问有什么解决方案么?谢谢
My code like below :
var label89val: LTMorphingLabel!
label89val = LTMorphingLabel(frame: CGRectMake(20, 10, 80, 80))
label89val.delegate = self
label89val.morphingEffect = .Scale
label89val.text = "0"
label89val.textColor = UIColor.whiteColor()
label89val.font = UIFont.boldSystemFontOfSize(23)
label89val.setNeedsDisplay()
self.view.addSubview(label89val)
always crash at
label89val.text = "0"
and get this error
fatal error: unexpectedly found nil while unwrapping an Optional value
There seem to be issues in animations with emojis... they pop up twice or aren't properly removed.
e.g. "Fire 🔥" morphed to "Zap⚡️" will result in "Zap " with a 🔥 and ⚡️ on top of each other. Is there a workaround for this?
I recognize that the amount of people using this library for emojis is probably minuscule, but still would be cool if there were an easy fix.
Love the library so much! Thanks for all your hard work!
I really like how the colon character (:
) is a little bit raised up and not touching the baseline in the San Francisco Display font introduced in WWDC 2015. Here is how it is supposed to look like:
However, once I changed the text of the label to something else with the .Fall
animation, the colon dropped onto the baseline:
I believe that this is caused by the way you draw the text using Core Text. Can you fix it?
Hi!
I'm new to cocoapods so maybe is my fault...but...
I have a problem running LTMorphingLabel.
I installed it following your instructions
Everything goes fine (CMD + u too)
But when I change class from UILabel to LTMorphingLabel I have an Xcode error saying "Use of undeclared identifier LTMorphingLabel".
I noticed frameworks links in red in the Pods -> Framework -> iOS folder so I relinked them, but nothing changes...
Environment
(Git demo works like a charm)
Thank you!
Is is possible to disable animations on/off?
It would be nice cos I don't want animations when I initially set text.
Thanks!
When you use languages like Arabic the text is displayed inverted :(
I install pod in my objective -c code and it's give me error like this for many class on pod file
DebugPrintable has been renamed to CustomStringConvertable
Thank you so much for this project and for doing it in swift.
however, I'm unable to use it and I don't understand what's wrong my code.
I've declared the outlet as
@IBOutlet var label: LTMorphingLabel!
then setting the text as
label.morphingEffect = .Scale
label.center = CGPointMake(160, 284)
label.text = "I'am a test label"
self.view.addSubview(label)
but for some reason the text doesn't change, plus I can't seem to run your project on simulator. it's successfully finish to load it, but nothing appear on simulator. thank you very much for any help .
If text is nil
and the label is laid out on screen, it crashes inside LTEmitter
.
Installed latest pod.
I tried to run LTMorphingLabel demo but get use of undeclared type 'LTEmitterView' error in XCode 6 beta 5
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.