Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
NSAttributedString for iOS
Search
Non Umemoto
October 04, 2012
Programming
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NSAttributedString for iOS
NSAttributedString for iOS in iOS Meetup Tokyo
Non Umemoto
October 04, 2012
More Decks by Non Umemoto
See All by Non Umemoto
Helpshiftについて - フィードバック駆動開発
umekun123
2
750
5分でわかるiOS7のiAdとTips
umekun123
0
6.1k
iOS6のNSAttributedString
umekun123
2
4.9k
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
Jetpack Compose メカニズム
skydoves
0
430
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
480
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2k
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
210
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1k
WebAssembly in Android Apps 〜 WASMはJNIの夢を見るか
keiji
1
100
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
350
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
210
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Thoughts on Productivity
jonyablonski
76
5.4k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
700
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
390
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
840
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
530
WENDY [Excerpt]
tessaabrams
14
39k
Transcript
Attributed Strings in iOS6 Non Umemoto @umekun123 1210݄5༵ۚ
iOS5 You have limited power with NSString 1210݄5༵ۚ
iOS5 NSString in UILabel 1210݄5༵ۚ
UILabel *label = [[UILabel alloc] init]; ~~ some codes for
label ~~ label.text = @"Listen to the web"; 1210݄5༵ۚ
iOS6 You have more power with NSAttributedString There are a
lot of hassles for using CoreText, right? 1210݄5༵ۚ
iOS6 NSAttributedString NSKernAttributeName 1210݄5༵ۚ
UILabel *label = [[UILabel alloc] init]; ~~ some codes for
label ~~ NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Listen to the web"]; NSInteger stringLength = [attString length]; [attString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(0, stringLength)]; label.attributedText = attString; 1210݄5༵ۚ
iOS6 NSAttributedString NSForegroundColorAttributeName 1210݄5༵ۚ
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Listen to the web"]; UIColor
*_red = [UIColor redColor]; [attString addAttribute:NSForegroundColorAttributeName value:_red range:NSMakeRange(0, 6)]; label.attributedText = attString; 1210݄5༵ۚ
iOS6 NSAttributedString NSUnderlineStyleAttributeName 1210݄5༵ۚ
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Listen to the web"]; [attString
addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(10, 7)]; label.attributedText = attString; 1210݄5༵ۚ
Available in UIKit • UITextView • UITextField • UILabel •
UIButton • UITableView • UIPickerVIew for example... 1210݄5༵ۚ
Available Attributes • Font • Text color • Paragraph style
• Text background color • Ligature, kerning, and baseline offset • Underline and strike-through • Stroke width and color • Shadow 1210݄5༵ۚ
One more thing A little bit advanced talk from now,
(and personal) 1210݄5༵ۚ
Can I use this for Syntax Highlighting on UITextView? 1210݄5༵ۚ
On my web speaker app, I wanna highlight the text
being spoken in real time. (Without using CoreText.) This is UITextView. 1210݄5༵ۚ
Something like this. With NSAttributedString. 1210݄5༵ۚ
Unfortunately, we need to reset UITextView every time setting a
new attributedString. textView.attributedText = attString So, it can be too SLOW for long text. (It must be ok for short text) 1210݄5༵ۚ
Possible textView replaceRange:(UITextRange *) withText:(NSString *) Not Possible textView replaceRange:(UITextRange
*) withText: (NSAttributedString *) 1210݄5༵ۚ
1210݄5༵ۚ
Anyway, it doesn’t matter for most of developers. NSAttributedString for
iOS is really nice! 1210݄5༵ۚ
Thank you If you are interested, check out the session
of WWDC2012 to find out more. “Session 222 - Introduction to Attributed Strings for iOS” 1210݄5༵ۚ