textview的文本在textview下重叠

时间:2016-12-09 10:42:20

标签: ios swift textview

我的问题很简单,我认为这是可能的,但我找不到。 我的设计是这样的

image

我将角半径设为textview,并将textContainerInset设置为左右两侧的填充

txtview_msg.textContainerInset = UIEdgeInsetsMake(5, 10, 10, 5)

现在我的问题就像前2行和后2行一样,我的文字在textview下面,所以我需要一些解决方案。

请帮帮我。谢谢

2 个答案:

答案 0 :(得分:0)

试试这段代码

UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView1;
txtview_msg.leftViewMode = UITextFieldViewModeAlways;

UIView *paddingView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView2;
txtview_msg.rightViewMode = UITextFieldViewModeAlways;

答案 1 :(得分:0)

You can create at first a view of same size how much you given, put cornerRadius how much you given in textview now. than create textview viewSize - corner radius. place the textview exactly in middle of view. set the constraints from that view only, than it will work perfect how you want. check this attached screenshot:

first one is simple text view In second I puted textview inside a view