123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // customerServiceViewController.m
- // 双子星云手机
- //
- // Created by xd h on 2024/6/26.
- //
- #import "customerServiceViewController.h"
- #import <Photos/Photos.h>
- @interface customerServiceViewController ()
- @end
- @implementation customerServiceViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- self.view.backgroundColor = HWF5F7FAColor;
- [self.titleLabel setText:NSLocalizedString(@"my_set_no_connect_kefu",nil)];
-
- [self initBaseUIFun];
- }
- #pragma mark
- - (void)initBaseUIFun
- {
- UIImageView *bgImageView = [[UIImageView alloc] init];
- bgImageView.image = [UIImage imageNamed:@"mine_customer_service"];
- //bgImageView.backgroundColor = [UIColor redColor];
- bgImageView.userInteractionEnabled = YES;
- [self.view addSubview:bgImageView];
-
- [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- //长按保存相片
- UIButton *tipLab = [[UIButton alloc] init];
-
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,172,48);
- gl.startPoint = CGPointMake(0.05, 0.63);
- gl.endPoint = CGPointMake(1, 0.5);
- gl.colors = @[(__bridge id)[UIColor hwColor:@"#E9B780"].CGColor, (__bridge id)[UIColor hwColor:@"#9A6B45"].CGColor];
- gl.locations = @[@(0), @(1.0f)];
- [tipLab.layer addSublayer:gl];
-
- tipLab.userInteractionEnabled = NO;
- [tipLab setTitle:@"长按保存图片" forState:UIControlStateNormal];
- [tipLab setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- tipLab.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
-
- //tipLab.text = @"长按保存图片";
- //tipLab.textAlignment = NSTextAlignmentCenter;
- //tipLab.font = [UIFont systemFontOfSize:14.0];
- //tipLab.textColor = [UIColor whiteColor];
- //tipLab.backgroundColor = [UIColor hwColor:@"#FFFFFF" alpha:0.2];
- [bgImageView addSubview:tipLab];
- tipLab.layer.cornerRadius = 24;
- tipLab.layer.masksToBounds = YES;
-
- [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(172);
- make.height.mas_equalTo(48);
- make.centerX.mas_equalTo(0);
- make.bottom.mas_equalTo(-35);
- }];
-
-
- // 创建长按手势识别器
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
-
- // 设置长按手势的最小按压时间
- longPress.minimumPressDuration = 2; // 2秒
-
- // 将手势识别器添加到视图上
- [bgImageView addGestureRecognizer:longPress];
- }
- - (void)longPress:(UILongPressGestureRecognizer *)gesture {
- if (gesture.state == UIGestureRecognizerStateBegan) {
- //NSLog(@"长按手势开始");
-
- UIImage *image = [UIImage imageNamed:@"mine_customer_service"];
-
- [self saveImage:image];
-
- }
- }
- - (void)saveImage:(UIImage *)image
- {
- //保存图片到【相机胶卷】
- /// 异步执行修改操作
- [[PHPhotoLibrary sharedPhotoLibrary]performChanges:^{
- [PHAssetChangeRequest creationRequestForAssetFromImage:image];
- } completionHandler:^(BOOL success, NSError * _Nullable error) {
- mainBlock(^{
- if (error) {
- //NSLog(@"%@",@"保存失败");
- [[iToast makeText:NSLocalizedString(@"common_save_fail",nil)] show];
- } else {
- //NSLog(@"%@",@"保存成功");
- [[iToast makeText:NSLocalizedString(@"common_save_suc",nil)] show];
- }
- });
-
- }];
- }
- @end
|