iOS常用OC-开发案例收集

iOS透传功能

2020-08-24  本文已影响0人  幽玄727

在iOS中有些功能需要使用到透传功能的功能(就是在A视图的上层有个B视图,用户点击了B视图,响应的是A视图的事件)

image.png

A视图中

    //透传功能
    FJLastView *lasetView = [[FJLastView alloc] initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, autoScaleW(100))];
    lasetView.backgroundColor = [UIColor blackColor];
    lasetView.alpha = 0.5;
    [self.view addSubview:lasetView];
    [self.view bringSubviewToFront:_lastView = lasetView];

B视图中

#import "FJLastView.h"

@implementation FJLastView


//点击了此视图,此视图不相应,让该视图层下一层响应点击事件
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{



    UIView *view = [super hitTest:point withEvent:event];


    if (view == self) {
        return nil;
    }

    return view;

}



@end
上一篇 下一篇

猜你喜欢

热点阅读