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,操作更友善哦
。