-
-
Save jjaffeux/3808548 to your computer and use it in GitHub Desktop.
ttt_attributed_label example
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
class ExampleViewController < UIViewController | |
def viewDidLoad | |
view.backgroundColor = :white.uicolor | |
frame = [[85, 200], [150, 20]] | |
lbl = TTTAttributedLabel.alloc.initWithFrame(frame).tap do |l| | |
l.backgroundColor = :clear.uicolor | |
l.textAlignment = UITextAlignmentRight | |
add_text(l) | |
end | |
view << lbl | |
end | |
def add_text(label) | |
text = "blue red and green" | |
label.setText(text, afterInheritingLabelAttributesAndConfiguringWithBlock: -> mutable{ | |
[:blue, :red, :green].each do |color| | |
range = mutable.string.rangeOfString(color.to_s, options:NSCaseInsensitiveSearch) | |
mutable.addAttribute KCTForegroundColorAttributeName, value:color.uicolor.CGColor, range:range | |
end | |
mutable | |
}) | |
label | |
end | |
end |
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
source "https://rubygems.org" | |
gem 'sugarcube' | |
gem 'motion-cocoapods', :git => 'https://github.com/HipByte/motion-cocoapods.git' # 1.1.4 seems broken |
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
Motion::Project::App.setup do |app| | |
... | |
app.frameworks += ['CoreText'] | |
app.pods do | |
pod 'TTTAttributedLabel' | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment