iOS & Swift

attributedText 의 몇가지 예

그리다웍스 2015. 6. 24. 16:56
반응형

돌아서면 잊어버리는 것들을 몇가지 적어본다.

1)

// range 의 범위는 표현하고자 하는 케이스마다 적절하게 수정한다.


NSRange range;

range.location = [문자열 length];

range.length = 1;    // 얼마나 적용할것인지




            

NSMutableAttributedString *attributedString = [[NSMutableAttributedString allocinitWithString:문자열];

            

[attributedString addAttribute:NSFontAttributeName

                         value:[UIFont boldSystemFontOfSize:12.0f]

                         range:range];

            

self.label.attributedText = attributedString;


2)

// 취소선

    [attributeString addAttribute:NSStrikethroughStyleAttributeName

                            value:@(NSUnderlineStyleSingle)

                            range:range];


반응형