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];

  • 相关阅读:
    c++模板类的使用,编译的问题
    js中对象深度拷贝的方法(浅拷贝)
    java8 Function 函数式接口的妙用
    Redis Web Ui管理工具
    前端省市联动,与django传递信息
    做人做事,行为规范
    几斤猫尿,醉享生活
    分布式系统之平台三大支柱
    祭奠十年,我今起步
    一步一步,从一而终
  • 原文地址:https://www.cnblogs.com/yingkong1987/p/3343931.html
Copyright © 2011-2022 走看看