• 实现图文混编界面


    //
    //  ViewController.m
    //  GCD多线程
    //
    //  Created by 张凯泽 on 16/3/9.
    //  Copyright © 2016年 rytong_zkz. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "ZKZTextAttachment.h"
    @interface ViewController ()<UITextViewDelegate>
    @end
    
    @implementation ViewController
    - (void)viewDidLoad {
        [super viewDidLoad];
        UITextView * textView = [[UITextView alloc]initWithFrame:self.view.frame];
        textView.delegate = self;
        [self.view addSubview:textView];
        //textView.userInteractionEnabled = NO;
        ZKZTextAttachment * attachment = [[[ZKZTextAttachment alloc]init]init];
        attachment.image = [UIImage imageNamed:@"1.png"];
        NSMutableAttributedString * attachmentString = (NSMutableAttributedString *)[NSAttributedString attributedStringWithAttachment:attachment];
        [textView.textStorage appendAttributedString:attachmentString];
        
        NSAttributedString * attachmentString1 = [[NSAttributedString alloc]initWithString:@"我饿我饿隔日 i 个本日 ver 好哦围观喝哦让别人弄不好v 会玩弄别惹您别人v 饿噢人不会热哦不容v 我呢热播如同被 one 女保暖热播女人旅呢哦日本呢肉搏王府井沛公就碰上个人评价饿哦让格局哦尔和包容他不会肉片;电话费都多家品牌非得哦 if 和哦哦的非农尔附近包容他人就播饿啊跑哦嗯热播耳机"];
        [textView.textStorage appendAttributedString:attachmentString1];
        
        
    }
    -(BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSTextAttachment *)textAttachment inRange:(NSRange)characterRange
    {
        NSLog(@"___________");
        return YES;
    }
    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
        
    }
    @end
    //
    //  ZKZTextAttachment.h
    //  GCD多线程
    //
    //  Created by 张凯泽 on 16/3/9.
    //  Copyright © 2016年 rytong_zkz. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface ZKZTextAttachment : NSTextAttachment
    
    @end
    //
    //  ZKZTextAttachment.m
    //  GCD多线程
    //
    //  Created by 张凯泽 on 16/3/9.
    //  Copyright © 2016年 rytong_zkz. All rights reserved.
    //
    
    #import "ZKZTextAttachment.h"
    
    @implementation ZKZTextAttachment
    -(CGRect)attachmentBoundsForTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(CGRect)lineFrag glyphPosition:(CGPoint)position characterIndex:(NSUInteger)charIndex
    {
        CGRect rect = CGRectMake(0, 0, 320, 200);
        return rect;
    }
    @end

  • 相关阅读:
    【转载】C/C++预处理器
    【转载】C/C++内存管理详解
    Spring知识点整理
    Hibernate知识点整理
    MyBatis知识点整理
    数据可视化(三)- Seaborn简易入门
    数据可视化(二)
    数据可视化(一)-Matplotlib简易入门
    Pandas之容易让人混淆的行选择和列选择
    Pandas简易入门(四)
  • 原文地址:https://www.cnblogs.com/zkzzkz/p/5257289.html
Copyright © 2020-2023  润新知