如何在iOS中使图像周围的文字变形? [英] How to warp text around image in iOS?

查看:70
本文介绍了如何在iOS中使图像周围的文字变形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义表格单元格.在该表格单元格上,我要显示 UIImage ,其中包裹了将从服务器获取的文本.我希望我的UI是这样的.

I have a custom table cell.On that table cell i want to display the UIImage wrapped with text which will be fetched from server.I want my UI something like this.

我有此代码

UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
self.textView.textContainer.exclusionPaths = @[imgRect]

上面的代码将在文本视图中为图像创建一个空白区域,但是如何在该区域显示图像呢?

The above code will create a blank space area for image in the text view but how to fit the image in that area ?

推荐答案

我通过将Imagview作为子视图添加到Texview中来解决了该问题

I solved it by adding the Imagview into the Texview as subview

UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 10, 100, 100)];
cell.tv_post.textContainer.exclusionPaths = @[imgRect];
        UIImageView *tv_image =[[UIImageView alloc]initWithFrame:CGRectMake(0, 10, 100, 100)];
[tv_image setImageWithURL:[NSURL URLWithString:[IMAGE_BASE_URL stringByAppendingString:user_post.post_video_thumbnail]]placeholderImage:[UIImage imageNamed:@"post_placeholder.png"]];
[cell.tv_post addSubview:tv_image];

这篇关于如何在iOS中使图像周围的文字变形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆