简体   繁体   中英

How to set UIView inside UITextView

The below picture shows that there is a view Inside TextView. Now I want that Where UIView ends from there textview starts editing, not only from Left-top also from left-bottom.

How to do it ?

Is it possible ?

If Yes, then how ?

If no, then any other suggestion ?

In case of text filed below code is applied for left padding

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

在此处输入图片说明

You can wrap textfiled using below code

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

And, now you can add any control in place of "imgRect"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM