iOS:add snapshot view

This commit is contained in:
pengfei.zhou 2021-07-14 14:22:58 +08:00 committed by osborn
parent 66d6c7de76
commit 4c7eb36565
7 changed files with 89 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright [2019] [Doric.Pub]
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright [2019] [Doric.Pub]
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -27,7 +27,7 @@
#import "DoricDevViewController.h"
#import "QRScanViewController.h"
#import "DoricDebugDriver.h"
#import "DoricRegistry.h"
#import "DoricSnapshotView.h"
@interface DoricContextCell : UITableViewCell
@property(nonatomic, strong) UILabel *tvId;
@ -121,7 +121,10 @@ - (void)onClick {
}
if ([DoricRegistry isEnableRenderSnapshot]) {
UIAlertAction *snapshot = [UIAlertAction actionWithTitle:@"Snapshot" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
DoricSnapshotView *doricSnapshotView = [DoricSnapshotView new];
doricSnapshotView.top = 50;
[self.doricContext.vc.view addSubview:doricSnapshotView];
[self.vc.navigationController popViewControllerAnimated:NO];
}];
[alertController addAction:snapshot];
}

View File

@ -1,5 +1,5 @@
/*
* Copyright [2019] [Doric.Pub]
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,5 +20,5 @@
#import <Foundation/Foundation.h>
@interface DoricFloatView : NSObject
@interface DoricFloatView : UIView
@end

View File

@ -1,5 +1,5 @@
/*
* Copyright [2019] [Doric.Pub]
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,8 +18,25 @@
//
#import "DoricFloatView.h"
#import <DoricCore/Doric.h>
@implementation DoricFloatView
- (instancetype)init {
if (self = [super init]) {
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onDrag:)];
[self addGestureRecognizer:gesture];
}
return self;
}
- (void)onDrag:(UIPanGestureRecognizer *)gesture {
CGPoint point = [gesture translationInView:self];
CGRect originalFrame = self.frame;
originalFrame.origin.x += point.x;
originalFrame.origin.y += point.y;
self.frame = originalFrame;
self.left = originalFrame.origin.x;
self.top = originalFrame.origin.y;
[gesture setTranslation:CGPointZero inView:self];
}
@end

View File

@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/7/14.
//
#import <Foundation/Foundation.h>
#import "DoricFloatView.h"
@interface DoricSnapshotView : DoricFloatView
@end

View File

@ -0,0 +1,36 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/7/14.
//
#import "DoricSnapshotView.h"
#import <DoricCore/Doric.h>
@implementation DoricSnapshotView
- (instancetype)init {
if (self = [super init]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
self.width = 20;
self.height = 20;
self.backgroundColor = [UIColor redColor];
}
@end