Slide 1

Slide 1 text

Attributed Strings in iOS6 13೥2݄24೔೔༵೔

Slide 2

Slide 2 text

ࣗݾ঺հ • കຊ ஆ @umekun123 • Lisgo (WebهࣄΛ͋ͱͰฉ͘ΞϓϦ) • umenon.com (ΞϓϦ։ൃฃಆه) 13೥2݄24೔೔༵೔

Slide 3

Slide 3 text

iOS5 NSStringͷࡉ͔͍ૢ࡞͕Ͱ͖Μʂ 13೥2݄24೔೔༵೔

Slide 4

Slide 4 text

iOS5 NSString in UILabel 13೥2݄24೔೔༵೔

Slide 5

Slide 5 text

UILabel *label = [[UILabel alloc] init]; ~~ লུ ~~ label.text = @"Listen to the web"; 13೥2݄24೔೔༵೔

Slide 6

Slide 6 text

iOS6 NSAttributedStringͰϞςϞςʂ CoreText࢖Θͳͯ͘΋͍Ζ͍ΖͰ͖ͪΌ͏ 13೥2݄24೔೔༵೔

Slide 7

Slide 7 text

iOS6 NSAttributedString NSKernAttributeName 13೥2݄24೔೔༵೔

Slide 8

Slide 8 text

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; 13೥2݄24೔೔༵೔

Slide 9

Slide 9 text

iOS6 NSAttributedString NSForegroundColorAttributeName 13೥2݄24೔೔༵೔

Slide 10

Slide 10 text

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; 13೥2݄24೔೔༵೔

Slide 11

Slide 11 text

iOS6 NSAttributedString NSUnderlineStyleAttributeName 13೥2݄24೔೔༵೔

Slide 12

Slide 12 text

NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Listen to the web"]; [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(10, 7)]; label.attributedText = attString; 13೥2݄24೔೔༵೔

Slide 13

Slide 13 text

UIKitͰ࢖͑·͢ • UITextView • UITextField • UILabel • UIButton • UITableView • UIPickerVIew ྫ͑͹... 13೥2݄24೔೔༵೔

Slide 14

Slide 14 text

AttributesͰ͍͡ΕΔࣄ • ϑΥϯτͷछྨ • ςΩετͷ৭ • ύϥάϥϑͷελΠϧ (ߴ͞ઃఆʹόά͋Δ) • ςΩετഎܠͷ৭ • จࣈִؒͷௐ੔ͱ͔ • Լઢɺத๮ઢ͚ͭͨΓ • Ө͚ͭͨΓ ͦͷଞʹ΋͍Ζ͍Ζ (ৄ͘͠͸υΩϡϝϯτͰ) 13೥2݄24೔೔༵೔

Slide 15

Slide 15 text

஍ຯͳ࢖༻ྫ NSMutableParagraphStyleͰɺೋߦͷ هࣄλΠτϧͷ্ԼͷִؒΛͭΊͯ ͍·͢ɻ 13೥2݄24೔೔༵೔

Slide 16

Slide 16 text

͓·͚ NSAttributedStringsͰ࢒೦ͩͬͨ͜ͱ 13೥2݄24೔೔༵೔

Slide 17

Slide 17 text

UITextViewͰϦΞϧλΠϜϋΠϥΠτ ͍ͨͬ͢͠ʂ 13೥2݄24೔೔༵೔

Slide 18

Slide 18 text

๻ͷLisgoͱ͍͏ಡΈ্͛ΞϓϦ ͰɺಡΈ্͛தͷςΩετΛ UITextView্ͰϦΞϧλΠϜϋΠϥ Πτʹ௅ઓɻ 13೥2݄24೔೔༵೔

Slide 19

Slide 19 text

NSAttributedStringͰϋΠϥΠτ ͢Δͱ͜Μͳײ͡ɻ ͓͓ɺ͜Ε͸Ͱ͖ͦ͏ɻ 13೥2݄24೔೔༵೔

Slide 20

Slide 20 text

࢒೦ͳ͓஌Βͤɻ ৽͍͠attributedStringΛηοτ͢Δͨͼʹ UITextviewΛϦηοτ͠ͳ͍ͱ͍͚ͳ͍ɻ textView.attributedText = attString ͳͷͰɺ௕͍จষͷதͰɺϋΠϥΠτՕॴ͕ ΆΜΆΜมΘΔͱॏ͘ͳͬͯΨΫΨΫɻ ϦΞϧλΠϜʹϋΠϥΠτՕॴม͑ͳ͍ͳΒϊʔϓϩϒϨϜͰ͢ɻ ※LisgoͰ͸݁ہUITextRange͔ΒCGRectऔͬͯViewష෇͚࣮ͯݱ͠·ͨ͠ɻ 13೥2݄24೔೔༵೔

Slide 21

Slide 21 text

͜Ε͸Ͱ͖Δͷʹ textView replaceRange:(UITextRange *) withText:(NSString *) ͜Ε͸Ͱ͖ͳ͍(ྦ) textView replaceRange:(UITextRange *) withText: (NSAttributedString *) 13೥2݄24೔೔༵೔

Slide 22

Slide 22 text

13೥2݄24೔೔༵೔

Slide 23

Slide 23 text

ࡉ͔͍ෆຬ͸͋Δ͚Ͳɺجຊతʹ NSAttributedsStrings͸ศརʂ ૉ੖Β͖͠iOS6ͷੈքɻ 13೥2݄24೔೔༵೔

Slide 24

Slide 24 text

͋Γ͕ͱ͏͍͟͝·ͨ͠ WWDC2012ͷηογϣϯݟΕ͹΋ͬͱࡉ͔͍෦෼͕Θ͔Δʂ “Session 222 - Introduction to Attributed Strings for iOS” 13೥2݄24೔೔༵೔