免费网站看v片在线第一次做,做网站吸引客户,网站关键词优化的步骤,湖北城乡住房建设厅网站YYText是强大的YYKit的一部分可以单独下载Powerful text framework for iOS to display and edit rich text. (Its a component ofYYKit)集成的时候建议使用cocopod管理1.里面主要两个控件#xff1a;YYTextView 和 YYLabel现在主要是YYTextview的简单使用YYText主要是NSMutab…YYText是强大的YYKit的一部分可以单独下载Powerful text framework for iOS to display and edit rich text. (Its a component ofYYKit)集成的时候建议使用cocopod管理1.里面主要两个控件YYTextView 和 YYLabel现在主要是YYTextview的简单使用YYText主要是NSMutableAttributedString来处理富文本 他的内部实现可以自己去深究。简单的图文并排使用NSMutableAttributedString创建一个对象 然后 appendAttributesString来拼接文字和图片(占位)直接上代码//// TextAndImageTextViewVC.h// YYTextDemo//// Created by linpeng on 16/3/13.// Copyright © 2016年 ibireme. All rights reserved.//#import interface TextAndImageTextViewVC : UIViewControllerend//// TextAndImageTextViewVC.m// YYTextDemo//// Created by linpeng on 16/3/13.// Copyright © 2016年 ibireme. All rights reserved.//#import TextAndImageTextViewVC.h#import YYText.h#import UIViewYYAdd.h#import YYTextView.h#import YYImage.h#import NSBundleYYAdd.h#import NSStringYYAdd.hinterface TextAndImageTextViewVC ()endYYTextView *textView;implementation TextAndImageTextViewVC- (void)viewDidLoad {[super viewDidLoad];[self.view setBackgroundColor:[UIColor whiteColor]];textView [[YYTextView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];textView.userInteractionEnabled YES;textView.textVerticalAlignment YYTextVerticalAlignmentTop;textView.size CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);//创建最主要的attribute文本NSMutableAttributedString *contentText [NSMutableAttributedString new];UIFont *font [UIFont systemFontOfSize:16];//图片资源YYImage *image [YYImage imageNamed:demo.jpg];image.preloadAllAnimatedImageFrames YES;//添加文本图片[contentText appendAttributedString:[[NSAttributedString alloc] initWithString:这是第一站图片 attributes:nil]];{YYAnimatedImageView *imageView [[YYAnimatedImageView alloc] initWithImage:image];imageView.frame CGRectMake(0, 0, textView.width - 10, textView.width/image.size.width*image.size.height);NSMutableAttributedString *attachText [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];[contentText appendAttributedString:attachText];}//添加文本图片[contentText appendAttributedString:[[NSAttributedString alloc] initWithString:\n 接下来是第二张 attributes:nil]];{YYAnimatedImageView *imageView2 [[YYAnimatedImageView alloc] initWithImage:image];imageView2.frame CGRectMake(0, 0, textView.width - 10, textView.width/image.size.width*image.size.height);NSMutableAttributedString *attachText2 [NSMutableAttributedString yy_attachmentStringWithContent:imageView2 contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView2.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];[contentText appendAttributedString:attachText2];}textView.attributedText contentText;[self.view addSubview:textView];//获取图片资源NSArray *attachments textView.textLayout.attachments;for(YYTextAttachment *attachment in attachments){YYAnimatedImageView *imageView attachment.content;YYImage *image (YYImage *)imageView.image;NSLog(获取到图片:%,image);}NSArray *attachmentRanges textView.textLayout.attachmentRanges;for (NSValue *range in attachmentRanges){NSRange r [range rangeValue];NSLog(资源所在位置%ld 长度: %ld,r.location,r.length);}}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.}*/end以上代码加上注释应该很容易理解就不多讲了 注意 \n 这个换行符的使用看效果图(可编辑的文本图片 有的app需要编辑文章功能 用这个就个可以大体实现了图片和文本都已经获取到了 到时后对应传到服务器之前没用YYTextview也实现过这种功能效果比较差用这个实现相当完美必须给YYText作者点个赞)