zoukankan      html  css  js  c++  java
  • 用UITextView加载rtfd文件

    用UITextView加载rtfd文件

    效果

    说明

    使用此方法可以实现十分简易的富文本显示效果,包括图文混排等等效果。

    源码

    //
    //  ViewController.m
    //  Rtfd
    //
    //  Created by YouXianMing on 15/9/10.
    //  Copyright (c) 2015年 ZiPeiYi. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController () {
        
        UITextView *_textView;
    }
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        
        [super viewDidLoad];
    
        NSString           *path   = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"rtfd"];
        NSAttributedString *string = [[NSAttributedString alloc] initWithFileURL:[NSURL fileURLWithPath:path]
                                                                      options:nil
                                                           documentAttributes:nil
                                                                        error:nil];
        
        _textView = [[UITextView alloc] initWithFrame:self.view.bounds];
        _textView.backgroundColor = [UIColor clearColor];
        _textView.attributedText  = string;
        _textView.editable        = NO;
        _textView.selectable      = NO;
        _textView.bounces         = YES;
        _textView.showsHorizontalScrollIndicator = NO;
        _textView.showsVerticalScrollIndicator   = NO;
        
        [self.view addSubview:_textView];
    }
    
    @end

    细节

    富文本中的图片

    对比图

  • 相关阅读:
    自动化CodeReview
    10个有关RESTful API良好设计的最佳实践
    ASP.NET Core 获取控制器上的自定义属性
    [转] Autofac创建实例的方法总结
    PetaPoco
    LogViewer
    hdoj:2047
    hdoj:2046
    hdoj:2045
    hdoj:2044
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4799064.html
Copyright © 2011-2022 走看看