LoginSignup
8

More than 5 years have passed since last update.

[iOS7][TextKit] letter press

Last updated at Posted at 2013-12-23

概要

iOS7 TexKitで letter pressをサポートするようになりました。前には名刺、はがきなどで使うことが多いのですが、アプリに使うと結構きれいな表示ができます。例としてはappleのnote,リマインダーのリストタイトルの方使ってます。
7minder-01.jpg

実装

実装は簡単、NSAttributedStringのattributeをNSTextEffectLetterpressStyleを設定するだけです。

-(void)p_pressLetter{
    //色とletterpress style設定
    NSDictionary *attrs = @{NSForegroundColorAttributeName : [UIColor redColor],
            NSTextEffectAttributeName : NSTextEffectLetterpressStyle};

    NSAttributedString *letterpressString = [[NSAttributedString alloc] initWithString:@"LOVE YOU FOR EVER"
    attributes:attrs];

    self.label.attributedText = letterpressString;
}

注意:

iPhone4サポートしない
https://developer.apple.com/library/ios/releasenotes/General/RN-iOSSDK-7.0/

参考

https://github.com/huiping192/iOS7/blob/master/TextkitSample/TextkitSample/RSViewController.m
https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/Reference/Reference.html

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8