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

  • 相关阅读:
    软件测试经典面试题汇总测试…(转载)
    loadrunner录制时弹出invalid application path
    【转】性能测试知多少:性能分析与…(转载)
    loadrunner小知识累积(转载)
    selenium定位方法总结
    [testng]Cannot find class in classpath
    java工程名前有红色感叹号
    jenkins slave节点问题总结
    scrapy爬虫框架
    Python监听鼠标键盘事件
  • 原文地址:https://www.cnblogs.com/yingkong1987/p/3343931.html
Copyright © 2011-2022 走看看