如何在UITextView中设置边距(填充)? [英] How to set margins (padding) in UITextView?

查看:182
本文介绍了如何在UITextView中设置边距(填充)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView文本编辑。默认情况下,它在文本周围有一个小的边距。我想将边距增加几个像素。

I have a UITextView for text editing. By default, it has a small margin around the text. I want to increase that margin by a few pixels.

contentInset属性提供了边距,但它不会更改文本换行宽度。文本以相同的宽度包装,额外的边距只是导致视图水平滚动。

The contentInset property gives me margins, but it does not change the text "wrap width". The text is wrapped at the same width, and the extra "margin" just causes the view to scroll horizontally.

有一种方法可以使UITextView具有一定的宽度显示具有较窄换行宽度的文本?

Is there a way to make a UITextView of a certain width display the text with a narrower "wrap width"?

推荐答案

从iOS 7开始,您可以使用 textContainerInset 属性:

Starting from iOS 7 you can use textContainerInset property:

textView.textContainerInset = UIEdgeInsetsMake(0, 20, 0, 20);

这篇关于如何在UITextView中设置边距(填充)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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