【问题标题】:How to set UIView inside UITextView如何在 UITextView 中设置 UIView
【发布时间】:2016-03-05 01:17:43
【问题描述】:

下图显示TextView里面有一个view。现在我想要 UIView 从那里结束的地方 textview 开始编辑,不仅从左上也从左下。

怎么做?

有可能吗?

如果是,那么如何?

如果没有,还有其他建议吗?

如果在代码下方提交的文本应用于左填充

UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
    textField.leftView = paddingView;
    textField.leftViewMode = UITextFieldViewModeAlways;

【问题讨论】:

标签: ios objective-c uiview uitextview


【解决方案1】:

您可以使用以下代码包装文本文件

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

而且,现在您可以添加任何控件来代替“imgRect”

 UIView *spacerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
spacerView1.backgroundColor = [UIColor redColor]; 
[textView addSubview:spacerView1];

【讨论】:

    猜你喜欢
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 1970-01-01
    • 2012-04-18
    • 2011-03-14
    • 1970-01-01
    • 2021-05-07
    相关资源
    最近更新 更多