1.在mian.m中
UIApplicationMain的第三个参数改为MYApplication
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, @"MYApplication", appDelegateClassName);
}
2.创建MYApplication .h .m
//
// MYApplication.h
// kkkvo
//
// Created by YYY on 2021/8/31.
// Copyright © 2021 YYY. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface MYApplication : UIApplication
@end
NS_ASSUME_NONNULL_END
//
// MYApplication.m
// kkkvo
//
// Created by YYY on 2021/8/31.
// Copyright © 2021 YYY. All rights reserved.
//
#import "MYApplication.h"
@implementation MYApplication
- (void)sendEvent:(UIEvent *)event{
[super sendEvent:event];
UITouch *touch = [event.allTouches anyObject];
CGPoint locationPointWindow = [touch preciseLocationInView:touch.window];
UIView *centerRadarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 7)];
centerRadarView.centerX = locationPointWindow.x;
centerRadarView.centerY = locationPointWindow.y;
centerRadarView.userInteractionEnabled = NO;
centerRadarView.backgroundColor = [UIColor clearColor];
centerRadarView.layer.borderColor = [UIColor blackColor].CGColor;
centerRadarView.layer.borderWidth = 3.5;
centerRadarView.layer.cornerRadius = 7/2.0;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[touch.window addSubview:centerRadarView];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.03 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.4 animations:^{
centerRadarView.width = 25;
centerRadarView.height = 25;
centerRadarView.layer.cornerRadius = 25/2.0;
centerRadarView.centerX = locationPointWindow.x;
centerRadarView.centerY = locationPointWindow.y;
centerRadarView.layer.borderWidth = 2;
} completion:^(BOOL finished) {
[centerRadarView removeFromSuperview];
}];
});
});
}
@end
3.原理是获取坐标点,加载到window上显示,通过圆角和宽高的线性动画,实现类似一块石头扔到水里的效果
4.当然可以只在当录屏情况下才添加这个效果,增过录屏的通知方法来打开关闭这个功能。
demo 链接: https://pan.baidu.com/s/1dM8iWK2hU3SupEfngIrOpg 提取码: kd8h 复制这段内容后打开百度网盘手机App,操作更方便哦
。