How to insert UIImageView in UITextView in the same way that iphone default message (SMS) app uses to insert multimedia content in the UITextView

后端 未结 4 1155
Happy的楠姐
Happy的楠姐 2021-01-18 21:16

I want to insert UIImageView in UITextView of Toolbar having send and camera button in the same way as iPhone default SMS app do.

4条回答
  •  礼貌的吻别
    2021-01-18 21:33

    You can implement it using UITextViewDelegate and ContentInset.

     - (void)viewDidLoad 
     {
        self.textView.delegate = self;
        [self.textView addSubview:self.addedView];
        [self.textView setContentInset:UIEdgeInsetsMake(0, 0, CGRectGetHeight(self.addedView.frame), 0)];
     }
    
    - (void)textViewDidChange:(UITextView *)textView
     {
        NSLog(@"%@",NSStringFromCGSize(textView.contentSize));
        __weak typeof(self) wself = self;
        [UIView animateWithDuration:0.5f animations:^{
          [wself.addedView setFrame:CGRectMake(0, textView.contentSize.height + 10, CGRectGetWidth(wself.addedView.frame), CGRectGetHeight(wself.addedView.frame))];
        }];
     }
    

提交回复
热议问题