在UITextView中添加UIImageView和UIButton

时间:2016-04-15 11:47:19

标签: ios uiimageview autolayout uitextview

我想在UIButton内添加UITextViewUITextView。单击“输入”按钮后,UIView高度会发生变化。我希望带有图像的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]; 和取消按钮放在文本上方。有可能吗?enter image description here

我尝试过使用Bezier路径。但是我的图像与文本一致,但我想让我的文字进入下一行。当我在此方法中添加按钮时,该按钮也不可用。

{{1}}

0 个答案:

没有答案