I want to add a UIImageView
and UIButton
inside UITextView
. UITextView
height changes on clicking enter button. I want the UIView
with image and cancel button to be placed above the text. Is it possible?
I have tried using Bezier path. But my image comes inline with the text, but I want my text to come in next line. Also the button is not tapable when I add it in this method.
UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 50, 50)];
self.commentText.textContainer.exclusionPaths = @[imgRect];
UIImageView *spacerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
spacerView.image = _pickedImageForComment;
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cancelButton addTarget:self
action:@selector(buttonsClicked:)
forControlEvents:UIControlEventTouchUpInside];
cancelButton.frame = CGRectMake(30, 0, 19, 19);
[cancelButton setImage:[UIImage imageNamed:@"remove_image"] forState:UIControlStateNormal];
[spacerView addSubview:cancelButton];
[_commentText addSubview:spacerView];