UITextView去掉单行的边距以及各种坑

self.textView.textContainer.lineFragmentPadding = 0;  
self.textView.textContainerInset = UIEdgeInsetsZero;  

只需要以上两行代码即可。这样我们在UITextView中设置的文字就可以左右两边对齐显示。

lineFragmentPading:官方描述:

The amount by which text is inset within line fragment rectangles.

The padding appears at the beginning and end of the line fragment rectangles. The layout manager uses this value to determine the layout width. The default value of this property is 5.0

Line fragment padding is not designed to express text margins. Instead, you should use insets on your text view, adjust the paragraph margin attributes, or change the position of the text view within its superview.


===============================坑2=============

设置textView的文字后,自动滚动到底部问题:

原问题描述地址:点击打开链接

利用上述方法会发现每当view出现的时候会滚动一下,用下面的方法可以完美解决,

解决方法:

[_contentLabel scrollRectToVisible:CGRectZero animated:NO];


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值