Skip to content

无侵入其它Class的代码、优雅的HitTest

License

Notifications You must be signed in to change notification settings

Avery-AN/HitTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HitTest

示意图如下:

示意图

如上图所示、各视图之间的关系是: ‘->表示子视图’
RedView -> BrownView -> YellowView -> GreenView


【 HitTest传统的处理方案 】

需要处理YellowView中的hittest方法、需要处理中BrownView的hittest方法;一共需要处理GreenView的两个父视图中的hittest方法。
如果YellowView是A大仙开发的、那么则需要告诉他需要处理一下YellowView中的hittest方法;
如果BrownView是B大姨开发的、那么也得告诉她需要处理一下BrownView中的hittest方法;
这么做特别麻烦不说、此处还得需要修改别人的代码(或者麻烦别人修改Ta的代码)、很是影响你开发与测试的进度。。。


【 优雅的处理方案 - Category 】

使用方法: 使用方法


【 为了规避不可预见的风险、以及性能方面的考虑、最好创建类似于”RedView+HitTest”的 Category、而不是直接使用本例中的”UIView+HitTest”Category 】

About

无侵入其它Class的代码、优雅的HitTest

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages