Last active
June 12, 2021 00:12
-
-
Save nunogoncalves/269d59db7afab880888f to your computer and use it in GitHub Desktop.
Setting an ellipsis changing from 1 to 3 dots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set a NSTimer to update call this function every n seconds to provide desired effect. | |
var numberOfDots = 3 | |
func applySearchingEffect() { | |
if let str = label.text { | |
let range = NSMakeRange(str.length - numberOfDots, numberOfDots) | |
var string = NSMutableAttributedString(string: str) | |
string.addAttribute(NSForegroundColorAttributeName, value: UIColor.clearColor(), range: range) | |
label.attributedText = string | |
numberOfDots-- | |
if numberOfDots < 0 { | |
numberOfDots = 3 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment