iOS让controller具有右滑pop的效果
程序员文章站
2023-10-06 11:22:26
ios让controller具有右滑pop的效果,首先要有navigationcontroller,在navigationcontroller的viewdidload方法里添加下面的代码
nso...
ios让controller具有右滑pop的效果,首先要有navigationcontroller,在navigationcontroller的viewdidload方法里添加下面的代码
nsobject *targetobjc = [[self.interactivepopgesturerecognizer valueforkey:@"_targets"] firstobject]; nsobject *target = [targetobjc valueforkey:@"target"]; uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:target action:@selector(handlenavigationtransition:)]; [self.view addgesturerecognizer:pan];
思路是利用runtime打印出uigesturerecognizer的属性,找到target存放的位置,继而找到self.interactivepopgesturerecognizer响应方法,重新创建一个平移手势加入到view上,利用响应者链实现我们的右滑pop效果。