Technology Sharing

Encapsulates an iOS comment pop-up window that imitates the effect of TikTok

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Demand background

Develop a pop-up window with interactive effects similar to the Tik Tok comment pop-up window, which supports sliding away.
Swipe to view comments
The effect is as follows
Please add a description of the image

Ideas

Create a view, place a tableView on it, add a sliding gesture to it, set the proxy, and implement the proxy method

  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    Supporting simultaneous response gestures is to enable us to continue to scroll the parent view when the tableView scrolls to the top, so as to achieve the effect of continuous sliding. If we do not set simultaneous response, when we scroll to the top of the tableView and continue to slide down, the entire pop-up window will not slide down. At the same time, when scrolling to the top, we need to set tableView.pangesture.enabled = NO, otherwise, when sliding back and forth repeatedly, it will cause the effect of two views scrolling at the same time.

Code

//
//  LBCommentPopView.m
//  TEXT
//
//  Created by mac on 2024/7/7.
//  Copyright © 2024 刘博. All rights reserved.
//

#import "LBCommentPopView.h"
#import "LBFunctionTestHeader.h"

@interface LBCommentPopView ()