zoukankan      html  css  js  c++  java
  • IOS7开发~NSAttributedString

    从 NSBundle 中读取rtf文本文件的内容,然后用UITextView展示:

    NSURL *url = [[NSBundle mainBundleURLForResource:@"Test.rtf" withExtension:nil];

        

        NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]

                                                     initWithFileURL:url

                                                     options:@{}

                                                     documentAttributes:nil

                                                     error:nil];

        

    //    返回相关联的字体,文字样式,并适当缩放用户选择的内容大小类别的一个实例。见UIFontDescriptor.h的完整列表

    //    + (UIFont *)preferredFontForTextStyle:(NSString *)style NS_AVAILABLE_IOS(7_0);

        [attributedText addAttribute:NSFontAttributeName

                                     value:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]

                                     range:NSMakeRange(0, attributedText.length)];

        

        UITextView *tView = [[UITextView allocinitWithFrame:CGRectMake(1010300400)

                                                textContainer:nil];

        tView.attributedText = attributedText;

        

        [self.view addSubview:tView];

  • 相关阅读:
    asp.net using library ClosedXML to export excel
    javascript 属性的特性
    javascript 如何避免属性访问错误
    javascript 继承
    Chapter 4 : Character Strings and Formatted Input/Output
    Chapter 3 :Differentiation
    Chapter 3 : Data and C
    Chapter 3 : Data and C
    Chapter 4 : Strings and Formatted Input/Output
    Chapter 1 :Preliminaries
  • 原文地址:https://www.cnblogs.com/yingkong1987/p/3343931.html
Copyright © 2011-2022 走看看