zoukankan      html  css  js  c++  java
  • 实现图文混编界面

    //
    //  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

  • 相关阅读:
    Leetcode Spiral Matrix
    Leetcode Sqrt(x)
    Leetcode Pow(x,n)
    Leetcode Rotate Image
    Leetcode Multiply Strings
    Leetcode Length of Last Word
    Topcoder SRM 626 DIV2 SumOfPower
    Topcoder SRM 626 DIV2 FixedDiceGameDiv2
    Leetcode Largest Rectangle in Histogram
    Leetcode Set Matrix Zeroes
  • 原文地址:https://www.cnblogs.com/zkzzkz/p/5257289.html
Copyright © 2011-2022 走看看