概要
iOS7 TexKitで letter pressをサポートするようになりました。前には名刺、はがきなどで使うことが多いのですが、アプリに使うと結構きれいな表示ができます。例としてはappleのnote,リマインダーのリストタイトルの方使ってます。
実装
実装は簡単、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