zoukankan      html  css  js  c++  java
  • 根据图片的像素 手势穿透问题

    新建一个UIImageView的子类。

    并重写 :

    -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
        
        unsigned char pixel[1] = {0};
        CGContextRef context = CGBitmapContextCreate(pixel,
                                                     1, 1, 8, 1, NULL,
                                                     kCGImageAlphaOnly);
        UIGraphicsPushContext(context);
        [self.image drawAtPoint:CGPointMake(-point.x, -point.y)];
        UIGraphicsPopContext();
        CGContextRelease(context);
        CGFloat alpha = pixel[0]/255.0f;
        NSLog(@"------%.2f---",alpha);
        BOOL transparent = alpha < 0.01f;
        
        return !transparent;
    }
    

     这样的话,这个图片的像素小于0.01的地方就不会响应手势,像素大于0.01的地方才会响应手势。

  • 相关阅读:
    highcharts
    iCheck
    MdiContainer
    wms-ssv数据字典
    hibernate 返回自定义对象
    XmlSerialize
    Db
    python groupby
    pom resource配置
    FastReport打印table
  • 原文地址:https://www.cnblogs.com/liuwenqiang/p/6526696.html
Copyright © 2011-2022 走看看