IOS中实现Lable点击事件

    xiaoxiao2021-12-14  16

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)]; // 1.创建一个点击事件,点击时触发labelClick方法 UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)]; // 2. 将点击事件添加到label上 label addGestureRecognizer:labelTapGestureRecognizer]; // 3. 设置label可被点击 label.userInteractionEnabled = YES; // 4. 在此方法中设置点击label后要触发的操作 - (void)labelClick { }
    转载请注明原文地址: https://ju.6miu.com/read-968119.html

    最新回复(0)