Commit b1790d27 by 刘卓鑫

新增长按识别二维码

parent 1634812e
...@@ -3,86 +3,4 @@ ...@@ -3,86 +3,4 @@
uuid = "0B73904D-2C2A-44A2-88D3-64B4C86B59B2" uuid = "0B73904D-2C2A-44A2-88D3-64B4C86B59B2"
type = "0" type = "0"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B7FD2D27-E0AA-44DB-B7D3-DDA090EDA1DF"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Tool(&#x5de5;&#x5177;)/ZXTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "127"
endingLineNumber = "127"
landmarkName = "+showCustomMsg:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "4FA80077-F8DB-4F6C-BFF3-A517F50085C1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Tool(&#x5de5;&#x5177;)/ZXTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "848"
endingLineNumber = "848"
landmarkName = "+requestDataWithType:url:para:completed:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "17CFB6A3-490C-4973-8493-478F4858F05B"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Task(&#x4efb;&#x52a1;)/ZXTaskViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "1231"
endingLineNumber = "1231"
landmarkName = "-unifiedInterstitialAdViewDidDismissVideoVC:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "00B8826C-F8BE-4788-99E0-056327F80256"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Task(&#x4efb;&#x52a1;)/ZXTaskViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "687"
endingLineNumber = "687"
landmarkName = "-nativeExpresInterstitialAd:didFailWithError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "79B52365-518B-4FC9-BCB7-64D2BCD2A0C7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Task(&#x4efb;&#x52a1;)/ZXTaskViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "616"
endingLineNumber = "616"
landmarkName = "-nativeExpressRewardedVideoAd:didFailWithError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>
...@@ -81,8 +81,6 @@ ...@@ -81,8 +81,6 @@
//设置根视图 //设置根视图
[self createWindow]; [self createWindow];
//token登录
[self tokenLogin];
//注册穿山甲 //注册穿山甲
[BUADTool setupBUAdSDK]; [BUADTool setupBUAdSDK];
//开屏广告 //开屏广告
...@@ -91,7 +89,10 @@ ...@@ -91,7 +89,10 @@
@strongify(self); @strongify(self);
[self createBaiduLauchAd]; [self createBaiduLauchAd];
}]; }];
//token登录
dispatch_async(dispatch_get_main_queue(), ^{
[self tokenLogin];
});
//版本检测 //版本检测
[self checkVersion]; [self checkVersion];
...@@ -105,6 +106,7 @@ ...@@ -105,6 +106,7 @@
//防止蓝牙洗浴后台运行被系统中断 //防止蓝牙洗浴后台运行被系统中断
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(ccc) userInfo:nil repeats:YES]; NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(ccc) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
NSLog(@"%@", CachePath);
return YES; return YES;
} }
#pragma mark - BaiduMobAdViewDelegate #pragma mark - BaiduMobAdViewDelegate
...@@ -128,6 +130,7 @@ ...@@ -128,6 +130,7 @@
-(void) failedDisplayAd:(BaiduMobFailReason) reason; -(void) failedDisplayAd:(BaiduMobFailReason) reason;
{ {
NSLog(@"delegate: failedDisplayAd %d", reason); NSLog(@"delegate: failedDisplayAd %d", reason);
[self.splashView removeFromSuperview];
} }
- (void)didAdImpressed { - (void)didAdImpressed {
...@@ -171,6 +174,7 @@ ...@@ -171,6 +174,7 @@
*/ */
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error { - (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error {
NSLog(@"穿山甲开屏广告加载失败"); NSLog(@"穿山甲开屏广告加载失败");
[splashAd removeFromSuperview];
} }
- (void) ccc { - (void) ccc {
//CK900100 //CK900100
...@@ -371,7 +375,7 @@ ...@@ -371,7 +375,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:kALI_PAY_RESULT object:resultDic]; [[NSNotificationCenter defaultCenter] postNotificationName:kALI_PAY_RESULT object:resultDic];
}]; }];
} else if ([url.host isEqualToString:@"pay"] || [url.host isEqualToString:@"oauth"]) { } else if ([url.host isEqualToString:@"pay"] || [url.host isEqualToString:@"oauth"] || [url.host isEqualToString:@"platformId=wechat"]) {
return [WXApi handleOpenURL:url delegate:self]; return [WXApi handleOpenURL:url delegate:self];
} }
return YES; return YES;
...@@ -402,7 +406,7 @@ ...@@ -402,7 +406,7 @@
}]; }];
} else if ([url.host isEqualToString:@"pay"] || [url.host isEqualToString:@"oauth"]) { } else if ([url.host isEqualToString:@"pay"] || [url.host isEqualToString:@"oauth"] || [url.host isEqualToString:@"platformId=wechat"]) {
return [WXApi handleOpenURL:url delegate:self]; return [WXApi handleOpenURL:url delegate:self];
} }
return YES; return YES;
...@@ -416,6 +420,10 @@ ...@@ -416,6 +420,10 @@
SendAuthResp *r = (SendAuthResp *)resp; SendAuthResp *r = (SendAuthResp *)resp;
[[NSNotificationCenter defaultCenter] postNotificationName:kWX_AUTH_RESULT object:r.code]; [[NSNotificationCenter defaultCenter] postNotificationName:kWX_AUTH_RESULT object:r.code];
} }
} else if ([resp isKindOfClass:[WXLaunchMiniProgramResp class]]) {
WXLaunchMiniProgramResp *re = (WXLaunchMiniProgramResp *)resp;
NSDictionary *dic = [re.extMsg mj_JSONObject];
[[NSNotificationCenter defaultCenter] postNotificationName:kWX_Min_RESULT object:dic];
} else { } else {
[[NSNotificationCenter defaultCenter] postNotificationName:kWX_PAY_RESULT object:@(resp.errCode)]; [[NSNotificationCenter defaultCenter] postNotificationName:kWX_PAY_RESULT object:@(resp.errCode)];
} }
...@@ -550,10 +558,6 @@ ...@@ -550,10 +558,6 @@
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification NS_AVAILABLE_IOS(12.0) { - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification NS_AVAILABLE_IOS(12.0) {
} }
#pragma mark - 点击推送 跳转 反馈/未支付订单 #pragma mark - 点击推送 跳转 反馈/未支付订单
- (void) jumpNotPayView:(NSDictionary *) userInfo { - (void) jumpNotPayView:(NSDictionary *) userInfo {
if (userInfo[@"CODE"] == nil || [userInfo[@"CODE"] isKindOfClass:[NSNull class]]) { if (userInfo[@"CODE"] == nil || [userInfo[@"CODE"] isKindOfClass:[NSNull class]]) {
......
// //
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
*/ */
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error { - (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error {
NSLog(@"穿山甲开屏广告加载失败"); NSLog(@"穿山甲开屏广告加载失败");
[splashAd removeFromSuperview];
} }
- (void) loadBannerAdWithController:(UIViewController *) viewController superView:(UIView *) superView isFirstPage:(BOOL) isFirst { - (void) loadBannerAdWithController:(UIViewController *) viewController superView:(UIView *) superView isFirstPage:(BOOL) isFirst {
...@@ -64,7 +65,8 @@ ...@@ -64,7 +65,8 @@
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90]; BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90; CGFloat bannerHeigh = kScreenWidth/600*90;
if (self.bannerView == nil) { if (self.bannerView == nil) {
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController imgSize:imgSize adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES];
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES];
self.bannerView.delegate = self; self.bannerView.delegate = self;
[superView addSubview:self.bannerView]; [superView addSubview:self.bannerView];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) { [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
...@@ -84,7 +86,7 @@ bottomMargin:(CGFloat) bottomMargin { ...@@ -84,7 +86,7 @@ bottomMargin:(CGFloat) bottomMargin {
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90]; BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90; CGFloat bannerHeigh = kScreenWidth/600*90;
if (self.bannerView == nil) { if (self.bannerView == nil) {
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController imgSize:imgSize adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES]; self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES];
self.bannerView.delegate = self; self.bannerView.delegate = self;
[superView insertSubview:self.bannerView atIndex:0]; [superView insertSubview:self.bannerView atIndex:0];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) { [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
...@@ -100,7 +102,7 @@ bottomMargin:(CGFloat) bottomMargin { ...@@ -100,7 +102,7 @@ bottomMargin:(CGFloat) bottomMargin {
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90]; BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90; CGFloat bannerHeigh = kScreenWidth/600*90;
if (self.bannerView == nil) { if (self.bannerView == nil) {
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController imgSize:imgSize adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES]; self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES];
self.bannerView.delegate = self; self.bannerView.delegate = self;
[superView insertSubview:self.bannerView atIndex:0]; [superView insertSubview:self.bannerView atIndex:0];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) { [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
......
// //
...@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZXAdTool : NSObject @interface ZXAdTool : NSObject
//开始获取开屏广告配置
+ (void) startLauchAdIsBaiduAd:(dispatch_block_t) baiduAd; + (void) startLauchAdIsBaiduAd:(dispatch_block_t) baiduAd;
@end @end
......
// //
...@@ -47,6 +47,8 @@ static NSString *kFailurMsg = @"数据加载失败,请检查一下当前网络 ...@@ -47,6 +47,8 @@ static NSString *kFailurMsg = @"数据加载失败,请检查一下当前网络
/*微信授权通知*/ /*微信授权通知*/
#define kWX_AUTH_RESULT @"wxaouthResult" #define kWX_AUTH_RESULT @"wxaouthResult"
/*微信小程序通知*/
#define kWX_Min_RESULT @"wxminiProgremResult"
/*微信支付结果通知*/ /*微信支付结果通知*/
#define kWX_PAY_RESULT @"wxPayResult" #define kWX_PAY_RESULT @"wxPayResult"
......
//
//
// ZXLongPressWebView.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/12/30.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXLongPressWebView : WKWebView
@end
NS_ASSUME_NONNULL_END
//
//
// ZXLongPressWebView.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/12/30.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXLongPressWebView.h"
#import "UIImage+InsetEdge.h"
#import "FSActionSheet.h"
@interface ZXLongPressWebView ()<FSActionSheetDelegate, UIGestureRecognizerDelegate>
/** */
@property (nonatomic, copy) NSString *qrCodeString;
/** */
@property (nonatomic, strong) UIImage *saveImage;
@end
@implementation ZXLongPressWebView
- (instancetype)init {
if (self = [super init]) {
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1;
longPress.delegate = self;
[self addGestureRecognizer:longPress];
}
return self;
}
#pragma mark - 长按相关============
- (BOOL)isAvailableQRcodeIn:(UIImage *)img{
UIImage *image = [img imageByInsetEdge:UIEdgeInsetsMake(-20, -20, -20, -20) withColor:[UIColor lightGrayColor]];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{}];
NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];
if (features.count >= 1) {
CIQRCodeFeature *feature = [features objectAtIndex:0];
_qrCodeString = [feature.messageString copy];
NSLog(@"二维码信息:%@", _qrCodeString);
return YES;
} else {
NSLog(@"无可识别的二维码");
return NO;
}
}
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender{
if (sender.state != UIGestureRecognizerStateBegan) {
return;
}
CGPoint touchPoint = [sender locationInView:self];
// 获取长按位置对应的图片url的JS代码
NSString *imgJS = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y];
// 执行对应的JS代码 获取url
[self evaluateJavaScript:imgJS completionHandler:^(id _Nullable imgUrl, NSError * _Nullable error) {
if (imgUrl) {
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imgUrl]];
UIImage *image = [UIImage imageWithData:data];
if (!image) {
NSLog(@"读取图片失败");
return;
}
FSActionSheet *actionSheet = nil;
if ([self isAvailableQRcodeIn:image]) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *ac1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
@weakify(self);
UIAlertAction *ac2 = [UIAlertAction actionWithTitle:@"保存图片" style:0 handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
UIImageWriteToSavedPhotosAlbum(self->_saveImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}];
UIAlertAction *ac3 = [UIAlertAction actionWithTitle:@"打开二维码" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
NSArray *arr = [self.qrCodeString componentsSeparatedByString:@";"];
if (arr && arr.count == 2) {
NSString *appid = arr.firstObject;
NSString *path = arr.lastObject;
[WXApi registerApp:appid];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = @"gh_c6510fd44b5f";
req.path = path;
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
}];
[alertController addAction:ac2];
[alertController addAction:ac3];
[alertController addAction:ac1];
[[ZXTool getCurrentVC] presentViewController:alertController animated:YES completion:^{
}];
}
}
}];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
NSString *message = @"Succeed";
if (error) {
message = @"Fail";
}
NSLog(@"save result :%@", message);
}
@end
//
//
// UIImage+InsetEdge.h
// WKWebView
//
// Created by etouch on 16/10/9.
// Copyright © 2016年 EL. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (InsetEdge)
- (UIImage *)imageByInsetEdge:(UIEdgeInsets)insets withColor:(UIColor *)color;
@end
//
//
// UIImage+InsetEdge.m
// WKWebView
//
// Created by etouch on 16/10/9.
// Copyright © 2016年 EL. All rights reserved.
//
#import "UIImage+InsetEdge.h"
@implementation UIImage (InsetEdge)
- (UIImage *)imageByInsetEdge:(UIEdgeInsets)insets withColor:(UIColor *)color{
CGSize size = self.size;
size.width -= insets.left + insets.right;
size.height -= insets.top + insets.bottom;
if (size.width <= 0 || size.height <= 0) {
return nil;
}
CGRect rect = CGRectMake(-insets.left, -insets.top, self.size.width, self.size.height);
UIGraphicsBeginImageContextWithOptions(size, NO, self.scale);
CGContextRef context = UIGraphicsGetCurrentContext();
if (color) {
CGContextSetFillColorWithColor(context, color.CGColor);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, CGRectMake(0, 0, size.width, size.height));
CGPathAddRect(path, NULL, rect);
CGContextAddPath(context, path);
CGContextEOFillPath(context);
CGPathRelease(path);
}
[self drawInRect:rect];
UIImage *insetEdgedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return insetEdgedImage;
}
@end
// //
...@@ -98,22 +98,22 @@ ...@@ -98,22 +98,22 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil];
// //测试按钮 //// //测试按钮
// UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)]; // UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)];
// [self.view addSubview:btn]; // [self.view addSubview:btn];
// btn.backgroundColor = [UIColor orangeColor]; // btn.backgroundColor = [UIColor orangeColor];
// [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) { // [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
// ZXTaskViewController *vc = [[NSClassFromString(@"ZXTaskViewController") alloc] init]; //// [kApplication openURL:[NSURL URLWithString:@"weixin://scanqrcode"]];
//
// [self.navigationController pushViewController:vc animated:YES];
// }]; // }];
//
if ([[kUserDefaults objectForKey:@"kAPP_IS_OPENB_TASK"] isEqualToString:@"yes"]) { if ([[kUserDefaults objectForKey:@"kAPP_IS_OPENB_TASK"] isEqualToString:@"yes"]) {
//查看任务相关内容 //查看任务相关内容
[self tashShow]; [self tashShow];
} }
} }
- (void) tashShow { - (void) tashShow {
@weakify(self); @weakify(self);
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:[NSString stringWithFormat:@"%@/dcxy/api/tasks/homePage", [kUserDefaults objectForKey:@"Task"]] para:nil completed:^(CommonModel *common, NSString *error) { [ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:[NSString stringWithFormat:@"%@/dcxy/api/tasks/homePage", [kUserDefaults objectForKey:@"Task"]] para:nil completed:^(CommonModel *common, NSString *error) {
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
self.tabBarController.tabBar.hidden = NO; self.tabBarController.tabBar.hidden = NO;
self.navigationController.navigationBar.hidden = YES; self.navigationController.navigationBar.hidden = YES;
[UIApplication sharedApplication].statusBarHidden = NO; [UIApplication sharedApplication].statusBarHidden = NO;
} }
#pragma mark - 收到支付完成的通知 #pragma mark - 收到支付完成的通知
- (void) payCompleted { - (void) payCompleted {
...@@ -152,8 +153,7 @@ ...@@ -152,8 +153,7 @@
[self changeIconAction]; [self changeIconAction];
}; };
[self.view addSubview:self.naHeader]; [self.view addSubview:self.naHeader];
//阿里妈妈测试代码
[ZXTool alimamaTest];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
......
// //
...@@ -10,9 +10,12 @@ ...@@ -10,9 +10,12 @@
#import <WebKit/WebKit.h> #import <WebKit/WebKit.h>
#import "ZXHomePageService.h" #import "ZXHomePageService.h"
#import "ZXHomePageAnnouce.h" #import "ZXHomePageAnnouce.h"
@interface ZXHomePageWebViewController ()<WKNavigationDelegate, WKUIDelegate> @interface ZXHomePageWebViewController ()<WKNavigationDelegate, WKUIDelegate>
/** */ /** */
@property (nonatomic, strong) WKWebView *webView; @property (nonatomic, strong) ZXLongPressWebView *webView;
@end @end
@implementation ZXHomePageWebViewController @implementation ZXHomePageWebViewController
...@@ -39,7 +42,7 @@ ...@@ -39,7 +42,7 @@
} }
- (WKWebView *)webView { - (WKWebView *)webView {
if (!_webView) { if (!_webView) {
_webView = [[WKWebView alloc] init]; _webView = [[ZXLongPressWebView alloc] init];
_webView.backgroundColor = [UIColor whiteColor]; _webView.backgroundColor = [UIColor whiteColor];
_webView.UIDelegate = self; _webView.UIDelegate = self;
_webView.navigationDelegate = self; _webView.navigationDelegate = self;
...@@ -57,6 +60,8 @@ ...@@ -57,6 +60,8 @@
self.titleStr = self.webView.title; self.titleStr = self.webView.title;
} }
[ZXTool hideLoadingAnimation]; [ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
} }
#pragma mark - ========== 加载失败 ========== #pragma mark - ========== 加载失败 ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
...@@ -199,4 +204,6 @@ ...@@ -199,4 +204,6 @@
}]; }];
} }
@end @end
// //
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved. // Copyright © 2019 Colorful Any Door. All rights reserved.
// //
#import <UIKit/UIKit.h> #import "ZXLongPressTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item); typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageBannerCell : UITableViewCell @interface ZXHomePageBannerCell : ZXLongPressTableViewCell
@property (nonatomic, strong) NSArray *banners; @property (nonatomic, strong) NSArray *banners;
/*点击了外部功能*/ /*点击了外部功能*/
@property (nonatomic, copy) clickOtherOperation clickOther; @property (nonatomic, copy) clickOtherOperation clickOther;
......
// //
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved. // Copyright © 2019 Colorful Any Door. All rights reserved.
// //
#import <UIKit/UIKit.h> #import "ZXLongPressTableViewCell.h"
@class ZXHomeSecondChildInfo; @class ZXHomeSecondChildInfo;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item); typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageSingleCell : UITableViewCell @interface ZXHomePageSingleCell : ZXLongPressTableViewCell
/** child */ /** child */
......
// //
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved. // Copyright © 2019 Colorful Any Door. All rights reserved.
// //
#import <UIKit/UIKit.h> #import "ZXLongPressTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item); typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageWindowCell : UITableViewCell @interface ZXHomePageWindowCell : ZXLongPressTableViewCell
/** */ /** */
@property (nonatomic, strong) NSArray *items; @property (nonatomic, strong) NSArray *items;
/*点击了外部功能*/ /*点击了外部功能*/
......
//
//
// ZXLongPressTableViewCell.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2020/1/2.
// Copyright © 2020 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXLongPressTableViewCell : UITableViewCell
@end
NS_ASSUME_NONNULL_END
//
//
// ZXLongPressTableViewCell.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2020/1/2.
// Copyright © 2020 Colorful Any Door. All rights reserved.
//
#import "ZXLongPressTableViewCell.h"
#import "UIImage+InsetEdge.h"
@interface ZXLongPressTableViewCell ()<UIGestureRecognizerDelegate>
/** */
@property (nonatomic, copy) NSString *qrCodeString;
/** */
@property (nonatomic, strong) UIImage *saveImage;
@end
@implementation ZXLongPressTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1;
longPress.delegate = self;
[self addGestureRecognizer:longPress];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - 长按相关============
- (BOOL)isAvailableQRcodeIn:(UIImage *)img{
UIImage *image = [img imageByInsetEdge:UIEdgeInsetsMake(-20, -20, -20, -20) withColor:[UIColor lightGrayColor]];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{}];
NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];
if (features.count >= 1) {
CIQRCodeFeature *feature = [features objectAtIndex:0];
_qrCodeString = [feature.messageString copy];
NSLog(@"二维码信息:%@", _qrCodeString);
return YES;
} else {
NSLog(@"无可识别的二维码");
return NO;
}
}
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender{
if (sender.state != UIGestureRecognizerStateBegan) {
return;
}
UIImage *image = [self screenShotWithView:self.contentView];
if (!image) {
NSLog(@"读取图片失败");
return;
}
if ([self isAvailableQRcodeIn:image]) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *ac1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
@weakify(self);
UIAlertAction *ac2 = [UIAlertAction actionWithTitle:@"保存图片" style:0 handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
UIImageWriteToSavedPhotosAlbum(self->_saveImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}];
UIAlertAction *ac3 = [UIAlertAction actionWithTitle:@"打开二维码" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
NSArray *arr = [self.qrCodeString componentsSeparatedByString:@";"];
if (arr && arr.count == 2) {
NSString *appid = arr.firstObject;
NSString *path = arr.lastObject;
[WXApi registerApp:appid];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = @"gh_c6510fd44b5f";
req.path = path;
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
}];
[alertController addAction:ac2];
[alertController addAction:ac3];
[alertController addAction:ac1];
[[ZXTool getCurrentVC] presentViewController:alertController animated:YES completion:^{
}];
}
}
//给指定view截屏
- (UIImage *) screenShotWithView:(UIView *) v {
UIGraphicsBeginImageContextWithOptions(v.bounds.size, YES, 0.0);
[v.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
NSString *message = @"Succeed";
if (error) {
message = @"Fail";
}
NSLog(@"save result :%@", message);
}
@end
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
@interface ZXHomePageAnnounceView()<UIScrollViewDelegate, WKNavigationDelegate, WKUIDelegate> @interface ZXHomePageAnnounceView()<UIScrollViewDelegate, WKNavigationDelegate, WKUIDelegate>
@property (nonatomic, strong) WKWebView *webView; @property (nonatomic, strong) ZXLongPressWebView *webView;
@property (nonatomic, strong) JXLayoutButton *agreedBtn; @property (nonatomic, strong) JXLayoutButton *agreedBtn;
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
[self.agreedBtn addTarget:self action:@selector(notAlert:) forControlEvents:UIControlEventTouchUpInside]; [self.agreedBtn addTarget:self action:@selector(notAlert:) forControlEvents:UIControlEventTouchUpInside];
self.webView = [[WKWebView alloc] init]; self.webView = [[ZXLongPressWebView alloc] init];
[bgView addSubview:self.webView]; [bgView addSubview:self.webView];
self.webView.UIDelegate = self; self.webView.UIDelegate = self;
...@@ -111,7 +111,8 @@ ...@@ -111,7 +111,8 @@
} }
}]; }];
[ZXTool hideLoadingAnimation]; [ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
} }
#pragma mark - ==========确定事件========== #pragma mark - ==========确定事件==========
- (void) okAction:(UIButton *) sender { - (void) okAction:(UIButton *) sender {
......
// //
...@@ -610,9 +610,9 @@ ...@@ -610,9 +610,9 @@
[self.tempData addObject:[result dataUsingEncoding:NSUTF8StringEncoding]]; [self.tempData addObject:[result dataUsingEncoding:NSUTF8StringEncoding]];
} else { } else {
//发送给蓝牙 //发送给蓝牙
if (data.length > 100) { // if (data.length > 100) {
return; // return;
} // }
[self.tempData addObject:data]; [self.tempData addObject:data];
} }
} }
......
// //
...@@ -905,9 +905,9 @@ ...@@ -905,9 +905,9 @@
NSLog(@"=============收到服务器返回的设备号"); NSLog(@"=============收到服务器返回的设备号");
} else { } else {
//发送给蓝牙 //发送给蓝牙
if (data.length > 100) { // if (data.length > 100) {
return; // return;
} // }
[self.tempData addObject:data]; [self.tempData addObject:data];
} }
} }
......
// //
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import <IQKeyboardManager/IQKeyboardManager.h> #import <IQKeyboardManager/IQKeyboardManager.h>
#import "ZXLoginAnimationView.h" #import "ZXLoginAnimationView.h"
#import "ZXOauthHasDCAccountViewController.h" #import "ZXOauthHasDCAccountViewController.h"
#import "XieYIViewController.h"
@interface ZXLoginViewController () @interface ZXLoginViewController ()
/** 用户名 */ /** 用户名 */
...@@ -49,9 +50,35 @@ ...@@ -49,9 +50,35 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
UILabel *versionLabel = [[UILabel alloc] init];
[self.view addSubview:versionLabel];
versionLabel.text = [NSString stringWithFormat:@"V %@", APPversion];
versionLabel.textColor = kTopicColor;
versionLabel.font = kFontSize(13 * k6Scale);
[versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom).offset(-10 * k6Scale);
make.right.equalTo(self.view.mas_right).offset(-25 * k6Scale);
}];
} UILabel *protocolLabel = [[UILabel alloc] init];
[self.view addSubview:protocolLabel];
protocolLabel.text = @"《用户协议 | 隐私政策》";
protocolLabel.textColor = kTopicColor;
protocolLabel.font = kFontSize(13 * k6Scale);
[protocolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom).offset(-10 * k6Scale);
make.left.equalTo(self.view.mas_left).offset(20 * k6Scale);
}];
protocolLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpProtocol)];
[protocolLabel addGestureRecognizer:tap];
}
#pragma mark - 隐私政策
- (void) jumpProtocol {
XieYIViewController * VC=[XieYIViewController new];
[self.navigationController pushViewController:VC animated:NO];
}
#pragma mark - 是否需要展示第三方登录按钮 #pragma mark - 是否需要展示第三方登录按钮
- (void) isNeedShowWXLogin { - (void) isNeedShowWXLogin {
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/app/customer/login/initdata", [kUserDefaults objectForKey:@"NEW_PAY"]] para:nil completed:^(CommonModel *common, NSString *error) { [ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/app/customer/login/initdata", [kUserDefaults objectForKey:@"NEW_PAY"]] para:nil completed:^(CommonModel *common, NSString *error) {
...@@ -104,16 +131,6 @@ ...@@ -104,16 +131,6 @@
}]; }];
[wxLoginBtn addTarget:self action:@selector(wxLogin:) forControlEvents:UIControlEventTouchUpInside]; [wxLoginBtn addTarget:self action:@selector(wxLogin:) forControlEvents:UIControlEventTouchUpInside];
UILabel *versionLabel = [[UILabel alloc] init];
[self.view addSubview:versionLabel];
versionLabel.text = [NSString stringWithFormat:@"v %@", APPversion];
versionLabel.textColor = kTopicColor;
versionLabel.font = kFontSize(13 * k6Scale);
[versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom).offset(-10 * k6Scale);
make.centerX.equalTo(self.view);
}];
} }
- (void) keyboardWillHide:(NSNotification *) nof { - (void) keyboardWillHide:(NSNotification *) nof {
......
// //
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
@interface XieYIViewController ()<WKNavigationDelegate,WKUIDelegate> @interface XieYIViewController ()<WKNavigationDelegate,WKUIDelegate>
@property(nonatomic,strong)WKWebView *webView; @property(nonatomic,strong)WKWebView *webView;
@property (strong, nonatomic) XieYiModel * xieyiModel; @property (strong, nonatomic) XieYiModel * xieyiModel;
/** */
@property (nonatomic, strong) UILabel *titleLabel;
@end @end
@implementation XieYIViewController @implementation XieYIViewController
...@@ -21,6 +23,8 @@ ...@@ -21,6 +23,8 @@
WKWebViewConfiguration *config = [WKWebViewConfiguration new]; WKWebViewConfiguration *config = [WKWebViewConfiguration new];
config.preferences.minimumFontSize = 10; config.preferences.minimumFontSize = 10;
_webView = [[WKWebView alloc]initWithFrame:CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height-64) configuration:config]; _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height-64) configuration:config];
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
} }
return _webView; return _webView;
} }
...@@ -77,6 +81,7 @@ ...@@ -77,6 +81,7 @@
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO]; [[UIApplication sharedApplication] setStatusBarHidden:NO];
self.navigationController.navigationBar.hidden = NO;
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
...@@ -104,8 +109,11 @@ ...@@ -104,8 +109,11 @@
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:item, nil]]; [self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:item, nil]];
UILabel* titleLabel = [MCCustomizeControl customizeLabel:@"注册协议" backgroundColor:[UIColor clearColor] font:[UIFont boldSystemFontOfSize:MC_NAVBAR_TITLE_FONT_SIZE] textColor:[UIColor colorWithHexString:@"#f3f3f3"] textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByWordWrapping]; self.titleLabel = [MCCustomizeControl customizeLabel:@"用户协议 | 隐私政策" backgroundColor:[UIColor clearColor] font:[UIFont boldSystemFontOfSize:MC_NAVBAR_TITLE_FONT_SIZE] textColor:[UIColor colorWithHexString:@"#f3f3f3"] textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByWordWrapping];
self.navigationItem.titleView = titleLabel; self.navigationItem.titleView = self.titleLabel;
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
// self.titleLabel.text = webView.title;
} }
- (void)backBtnFuc{ - (void)backBtnFuc{
[SVProgressHUD dismiss]; [SVProgressHUD dismiss];
......
// //
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "AboutUs.h" #import "AboutUs.h"
#import <WebKit/WebKit.h> #import <WebKit/WebKit.h>
#import "AboutUsModel.h" #import "AboutUsModel.h"
#import "XieYIViewController.h"
#import "enlargeClickRegionBtn.h" #import "enlargeClickRegionBtn.h"
@interface AboutUs ()<WKNavigationDelegate,WKUIDelegate,UIGestureRecognizerDelegate> @interface AboutUs ()<WKNavigationDelegate,WKUIDelegate,UIGestureRecognizerDelegate>
@property (nonatomic,strong) WKWebView* webView; @property (nonatomic,strong) WKWebView* webView;
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
NSURL * webUrl = [NSURL URLWithString:url]; NSURL * webUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:webUrl]; NSURLRequest* request = [NSURLRequest requestWithURL:webUrl];
[self.webView loadRequest:request]; [self.webView loadRequest:request];
[self.view addSubview:self.webView];
} }
else{ else{
...@@ -75,7 +76,7 @@ ...@@ -75,7 +76,7 @@
config.preferences.minimumFontSize = 10; config.preferences.minimumFontSize = 10;
_webView = [[WKWebView alloc]initWithFrame:CGRectMake(0,self.isFromSimple?kTopHeight:0,self.view.bounds.size.width, self.view.bounds.size.height-64) configuration:config]; _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0,self.isFromSimple?kTopHeight:0,self.view.bounds.size.width, self.view.bounds.size.height-64) configuration:config];
_webView.scrollView.showsVerticalScrollIndicator=NO; _webView.scrollView.showsVerticalScrollIndicator=NO;
[self.view addSubview:_webView];
} }
return _webView; return _webView;
} }
...@@ -97,6 +98,24 @@ ...@@ -97,6 +98,24 @@
} else { } else {
[self initNavButtons]; [self initNavButtons];
} }
UILabel *protocolLabel = [[UILabel alloc] init];
[self.view insertSubview:protocolLabel aboveSubview:self.webView];
protocolLabel.text = @"《用户协议 | 隐私政策》";
protocolLabel.textColor = kTopicColor;
protocolLabel.font = kFontSize(13 * k6Scale);
[protocolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom).offset(-10 * k6Scale);
make.centerX.equalTo(self.view.mas_centerX);
}];
protocolLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpProtocol)];
[protocolLabel addGestureRecognizer:tap];
}
#pragma mark - 隐私政策
- (void) jumpProtocol {
XieYIViewController * VC=[XieYIViewController new];
[self.navigationController pushViewController:VC animated:NO];
} }
#pragma mark - ========== 创建导航栏 ========== #pragma mark - ========== 创建导航栏 ==========
- (void) createNabar { - (void) createNabar {
...@@ -170,7 +189,7 @@ ...@@ -170,7 +189,7 @@
} }
/* /*
返回 返回
*/ */
-(void)backBtnFuc -(void)backBtnFuc
{ {
......
// //
...@@ -808,6 +808,12 @@ heightForFooterInSection:(NSInteger)section { ...@@ -808,6 +808,12 @@ heightForFooterInSection:(NSInteger)section {
m.topic = @"京东支付"; m.topic = @"京东支付";
m.payType = @"4"; m.payType = @"4";
[set addObject:m]; [set addObject:m];
} else if ([dic[@"id"] integerValue] == 10) {
ZXPayTypeModel *m = [[ZXPayTypeModel alloc] init];
m.icon = @"weixin";
m.topic = @"微信支付";
m.payType = @"10";
[set addObject:m];
} }
} }
NSArray *arr = [[set allObjects] sortedArrayUsingComparator:^NSComparisonResult(ZXPayTypeModel* _Nonnull obj1, ZXPayTypeModel *obj2) { NSArray *arr = [[set allObjects] sortedArrayUsingComparator:^NSComparisonResult(ZXPayTypeModel* _Nonnull obj1, ZXPayTypeModel *obj2) {
......
// //
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
UIButton *confirmBtn; UIButton *confirmBtn;
NSInteger payTypeValue;//支付方式对应的类型 NSInteger payTypeValue;//支付方式对应的类型
} }
/** */
@property (nonatomic, copy) NSString *wxCode;
@end @end
@implementation ZXConfirmPayViewController @implementation ZXConfirmPayViewController
...@@ -92,6 +93,10 @@ ...@@ -92,6 +93,10 @@
payStyleLabel.text = @"京东支付"; payStyleLabel.text = @"京东支付";
payTypeValue = 4; payTypeValue = 4;
icon.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"JD"].CGImage); icon.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"JD"].CGImage);
} else if ([self.payType isEqualToString:@"10"]) {
payStyleLabel.text = @"微信支付";
icon.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"weixin"].CGImage);
payTypeValue = 10;
} }
UIView *bg = [[UIView alloc] init]; UIView *bg = [[UIView alloc] init];
...@@ -123,12 +128,18 @@ ...@@ -123,12 +128,18 @@
self.navigationController.navigationBar.hidden = YES; self.navigationController.navigationBar.hidden = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aliPaySuccess:) name:kALI_PAY_RESULT object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aliPaySuccess:) name:kALI_PAY_RESULT object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wxPaySuccess:) name:kWX_PAY_RESULT object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wxPaySuccess:) name:kWX_PAY_RESULT object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wechatMiniResult:) name:kWX_Min_RESULT object:nil];
} }
- (void) viewWillDisappear:(BOOL)animated { - (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO; self.navigationController.navigationBar.hidden = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self name:kALI_PAY_RESULT object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:kALI_PAY_RESULT object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_PAY_RESULT object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_PAY_RESULT object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_AUTH_RESULT object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_Min_RESULT object:nil];
} }
#pragma mark - ========== 创建导航栏 ========== #pragma mark - ========== 创建导航栏 ==========
- (void) createNabar { - (void) createNabar {
...@@ -162,7 +173,24 @@ ...@@ -162,7 +173,24 @@
} }
- (void) confirmBtnFuc { - (void) confirmBtnFuc {
if (payTypeValue == 10) {
if ([UserManager sharedUserManager].user.isWXAuthLogin) {
//已经绑定
[self openMinProgrom];
} else {
//授权
[WXApi registerApp:@"wx41cd01f1eb664e21" enableMTA:YES];
SendAuthReq *req = [[SendAuthReq alloc] init];
req.scope = @"snsapi_userinfo";
req.openID = @"wx41cd01f1eb664e21";
req.state = @"1";
[WXApi sendReq:req];
}
} else {
[self requestPay:self.rechargeId payType:payTypeValue]; [self requestPay:self.rechargeId payType:payTypeValue];
}
} }
#pragma mark - ========== 创建充值订单 ========== #pragma mark - ========== 创建充值订单 ==========
...@@ -393,4 +421,65 @@ ...@@ -393,4 +421,65 @@
// //
// //
//} //}
#pragma mark - 微信授权成功
- (void) aouthSuccess:(NSNotification *) nof {
if ([self.wxCode isEqualToString:nof.object]) {
return;
}
self.wxCode = nof.object;
NSLog(@"请求微信授权登录----%@", self.wxCode);
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
[manager GET:[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx41cd01f1eb664e21&secret=d709419cf1ba7ed33e6337bd9396bef1&code=%@&grant_type=authorization_code", nof.object] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
self.wxCode = @"";
if (responseObject != nil && responseObject[@"openid"] != nil) {
//
[ZXTool requestDataWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/dcxy/wechat/authlogin/bind?thridUUId=%@", [kUserDefaults objectForKey:@"NEW_PAY"], responseObject[@"openid"]] para:nil completed:^(CommonModel *common, NSString *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
if (error) {
[ZXTool showText:error];
} else {
[UserManager sharedUserManager].user.isWXAuthLogin = YES;
[[UserManager sharedUserManager].user update];
[self openMinProgrom];
}
});
}];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:@"微信授权失败,请稍后再试"];
});
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:error.userInfo[@"NSLocalizedDescription"]];
});
}];
}
#pragma mark - 拉起小程序
- (void) openMinProgrom {
[WXApi registerApp:@"wx41cd01f1eb664e21"];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = @"gh_c6510fd44b5f";
req.path = [NSString stringWithFormat:@"/pages/AppPay/AppPay?token=%@&clientIp=%@&id=%ld&isFirstRecharge=%d&customerId=%@", CacheToken, [ZXTool getCurentLocalIP], self.rechargeId, self.isFirstRecharge?0:1, CacheUserId];
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
#pragma mark - 微信小程序回调
- (void) wechatMiniResult:(NSNotification *) nof {
NSDictionary *dic = nof.object;
dispatch_async(dispatch_get_main_queue(), ^{
if ([dic[@"code"] integerValue] == 1) {
[self paySuccessAndRefreshUserInfo];
} else {
[ZXTool showText:dic[@"msg"]];
}
});
}
@end @end
//
//
// ZXPlayAdViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/12/16.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXPlayAdViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
//
// ZXPlayAdViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/12/16.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXPlayAdViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
@interface ZXPlayAdViewController ()
@end
@implementation ZXPlayAdViewController
- (void)viewDidLoad {
[super viewDidLoad];
//文件操作对象
NSString *filePath = [CachePath stringByAppendingString:@"/bu_fullCaches"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *fileList = [[NSArray alloc] init];
//fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组
fileList = [fileManager contentsOfDirectoryAtPath:filePath error:&error];
NSInteger index = arc4random() % fileList.count;
NSLog(@"Every Thing in the dir:%@",fileList);
NSURL *url = [NSURL fileURLWithPath:[filePath stringByAppendingPathComponent:fileList[index]]];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
AVURLAsset *asset1 = [AVURLAsset URLAssetWithURL:url options:nil];
long long second = 0;
// 获取视频总时长,单位秒
second = asset1.duration.value / asset1.duration.timescale;
AVPlayerItem *playerItem1 = [AVPlayerItem playerItemWithAsset:asset1];
AVPlayer *avPlayer = [AVPlayer playerWithPlayerItem: playerItem1];
AVPlayerLayer *avlayer1 = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
avlayer1.frame = (CGRect){0, 0, self.view.frame.size.width, self.view.frame.size.height};
avlayer1.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:avlayer1];
[avPlayer play];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
// //
...@@ -172,7 +172,6 @@ typedef void(^checkIsOldCustomer)(BOOL isOld); ...@@ -172,7 +172,6 @@ typedef void(^checkIsOldCustomer)(BOOL isOld);
+ (NSString *) formatJumpUrl:(NSString *) jumpUrl; + (NSString *) formatJumpUrl:(NSString *) jumpUrl;
+(void) alimamaTest;
//ip //ip
+ (NSString*)getCurentLocalIP; + (NSString*)getCurentLocalIP;
......
// //
...@@ -1741,78 +1741,46 @@ void ProviderReleaseData (void *info, const void *data, size_t size){ ...@@ -1741,78 +1741,46 @@ void ProviderReleaseData (void *info, const void *data, size_t size){
} }
+(void) alimamaTest {
if (![CacheCampusId isEqualToString:@"15"]) {
[[ZXAdViewService sharedManager] GET:@"https://crossoverliuzx.github.io/json.txt" parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
if ([responseObject[@"code"] integerValue] == 1) {
if ([[UserManager sharedUserManager].user.customerSex isEqualToString:@"1"]) {
NSArray *maleList = responseObject[@"data"][@"male"];
//随机数
NSInteger radom = arc4random() % maleList.count;
NSString *code = maleList[radom][@"name"];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = code;
} else {
NSArray *femaleList = responseObject[@"data"][@"female"];
NSInteger radom = arc4random() % femaleList.count;
NSString *code = femaleList[radom][@"name"];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = code;
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
}
#pragma mark - 获取ip地址 #pragma mark - 获取ip地址
+ (NSString*)getCurentLocalIP{ + (NSString*)getCurentLocalIP{
    NSString*address =nil; NSString*address =nil;
    struct ifaddrs*interfaces =NULL;
    struct ifaddrs*temp_addr =NULL;
    int success =0;
    // retrieve the current interfaces - returns 0 on success struct ifaddrs*interfaces =NULL;
    success =getifaddrs(&interfaces); struct ifaddrs*temp_addr =NULL;
    if(success ==0) { int success =0;
        // Loop through linked list of interfaces // retrieve the current interfaces - returns 0 on success
        temp_addr = interfaces; success =getifaddrs(&interfaces);
        while(temp_addr !=NULL) { if(success ==0) {
            NSLog(@"%d",temp_addr->ifa_addr->sa_family); // Loop through linked list of interfaces
            if(temp_addr->ifa_addr->sa_family==AF_INET|| temp_addr->ifa_addr->sa_family==AF_INET6|| temp_addr->ifa_addr->sa_family==AF_LINK) { temp_addr = interfaces;
                if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) { while(temp_addr !=NULL) {
NSLog(@"%d",temp_addr->ifa_addr->sa_family);
                    // Get NSString from C String if(temp_addr->ifa_addr->sa_family==AF_INET|| temp_addr->ifa_addr->sa_family==AF_INET6|| temp_addr->ifa_addr->sa_family==AF_LINK) {
                    address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)]; if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
                } // Get NSString from C String
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
            } }
}
            temp_addr = temp_addr->ifa_next; temp_addr = temp_addr->ifa_next;
}
        } }
// Free memory
    }
    // Free memory
    freeifaddrs(interfaces); freeifaddrs(interfaces);
    return address; return address;
} }
......
/* /*
...@@ -18,13 +18,18 @@ ...@@ -18,13 +18,18 @@
"Replay" = "Click to replay"; "Replay" = "Click to replay";
"Continue" = "Continue to play"; "Continue" = "Continue to play";
"Skip" = "Skip"; "Skip" = "Skip";
"Feedback" = "Feedback";
"FeedbackStr1" = "Thank you for your feedback.";
"FeedbackStr2" = "We will try to do better.";
"FeedbackStr3" = "You have submitted feedback.";
"FeedbackStr4" = "please don’t submit it again!";
"ViewNow" = "View now"; "ViewNow" = "View now";
"Download" = "Download"; "Download" = "Download";
"LoadFailure" = "Failed to load, and click to try again"; "LoadFailure" = "Failed to load, and click to try again";
"GetRewardAfterWatching" = "Get reward after watching the full video"; "GetRewardAfterWatching" = "Get reward after watching the full video";
"GiveUpReward" = "Give up reward"; "GiveUpReward" = "Give up reward";
"ContinueWatching" = "Continue watching"; "ContinueWatching" = "Continue watching";
"CanbeTurnedOffAfter" = "can be turned off after %ds"; "CanbeTurnedOffAfter" = "Skip after %ds";
"Get" = "Get"; "Get" = "Get";
"View" = "View"; "View" = "View";
// Icon // Icon
/* /*
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
"Replay" = "リプレイ"; "Replay" = "リプレイ";
"Continue" = "再生し続ける"; "Continue" = "再生し続ける";
"Skip" = "skip"; "Skip" = "skip";
"Feedback" = "Feedback";
"FeedbackStr1" = "Thank you for your feedback.";
"FeedbackStr2" = "We will try to do better.";
"FeedbackStr3" = "You have submitted feedback.";
"FeedbackStr4" = "please don’t submit it again!";
"ViewNow" = "詳細を見る"; "ViewNow" = "詳細を見る";
"Download" = "download"; "Download" = "download";
"LoadFailure" = "ロードに失敗しました。クリックして再度お試しください"; "LoadFailure" = "ロードに失敗しました。クリックして再度お試しください";
......
/* /*
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
"Replay" = "点击重播"; "Replay" = "点击重播";
"Continue" = "继续播放"; "Continue" = "继续播放";
"Skip" = "跳过"; "Skip" = "跳过";
"Feedback" = "反馈";
"FeedbackStr1" = "感谢您的反馈!";
"FeedbackStr2" = "我们将为您带来更优质的广告体验";
"FeedbackStr3" = "您已提交过反馈!";
"FeedbackStr4" = "请勿反复提交";
"ViewNow" = "立即查看"; "ViewNow" = "立即查看";
"Download" = "立即下载"; "Download" = "立即下载";
"LoadFailure" = "加载失败,点击重试"; "LoadFailure" = "加载失败,点击重试";
......
// //
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#import <BUAdSDK/BUNativeExpressInterstitialAd.h> #import <BUAdSDK/BUNativeExpressInterstitialAd.h>
#import <BUAdSDK/BUNativeExpressRewardedVideoAd.h> #import <BUAdSDK/BUNativeExpressRewardedVideoAd.h>
#import <BUAdSDK/BUNativeExpressFullscreenVideoAd.h> #import <BUAdSDK/BUNativeExpressFullscreenVideoAd.h>
#import <BUAdSDK/BUNativeExpressSplashView.h>
/// banner ads /// banner ads
#import <BUAdSDK/BUBannerAdView.h> #import <BUAdSDK/BUBannerAdView.h>
......
// //
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, BUUserGender) { typedef NS_ENUM(NSInteger, BUOfflineType) {
BUUserGenderUnknown, BUOfflineTypeNone, // Do not set offline
BUUserGenderMan, BUOfflineTypeProtocol, // Offline dependence NSURLProtcol
BUUserGenderWoman, BUOfflineTypeWebview, // Offline dependence WKWebview
}; };
typedef NS_ENUM(NSInteger, BUAdSDKLogLevel) { typedef NS_ENUM(NSInteger, BUAdSDKLogLevel) {
......
// //
...@@ -17,34 +17,35 @@ ...@@ -17,34 +17,35 @@
@param appID : the unique identifier of the App @param appID : the unique identifier of the App
*/ */
+ (void)setAppID:(NSString *)appID; + (void)setAppID:(NSString *)appID;
/** /**
Configure development mode. Configure development mode.
@param level : default BUAdSDKLogLevelNone @param level : default BUAdSDKLogLevelNone
*/ */
+ (void)setLoglevel:(BUAdSDKLogLevel)level; + (void)setLoglevel:(BUAdSDKLogLevel)level;
/// Set the gender of the user.
+ (void)setUserGender:(BUUserGender)userGender;
/// Set the age of the user.
+ (void)setUserAge:(NSUInteger)userAge;
/* Set the COPPA of the user, COPPA is the short of Children's Online Privacy Protection Rule, the interface only works in the United States. /* Set the COPPA of the user, COPPA is the short of Children's Online Privacy Protection Rule, the interface only works in the United States.
* @params Coppa 0 adult, 1 child * @params Coppa 0 adult, 1 child
*/ */
+ (void)setCoppa:(NSUInteger)Coppa; + (void)setCoppa:(NSUInteger)Coppa;
/// Set the user's keywords, such as interests and hobbies, etc. /// Set the user's keywords, such as interests and hobbies, etc.
/// Must obtain the consent of the user before incoming.
+ (void)setUserKeywords:(NSString *)keywords; + (void)setUserKeywords:(NSString *)keywords;
/// set additional user information. /// set additional user information.
+ (void)setUserExtData:(NSString *)data; + (void)setUserExtData:(NSString *)data;
/// Set whether the app is a paid app, the default is a non-paid app /// Set whether the app is a paid app, the default is a non-paid app.
/// Must obtain the consent of the user before incoming
+ (void)setIsPaidApp:(BOOL)isPaidApp; + (void)setIsPaidApp:(BOOL)isPaidApp;
/// Solve the problem when your WKWebview post message empty,default is BUOfflineTypeWebview
+ (void)setOfflineType:(BUOfflineType)type;
/// get appID
+ (NSString *)appID; + (NSString *)appID;
/// get isPaidApp
+ (BOOL)isPaidApp; + (BOOL)isPaidApp;
@end @end
......
// //
...@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, strong, readonly, nonnull) UIButton *dislikeButton; @property (nonatomic, strong, readonly, nonnull) UIButton *dislikeButton;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithIdentifier:(NSString *)slotID - (instancetype)initWithIdentifier:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController rootViewController:(UIViewController *)rootViewController
adSize:(CGSize)adSize adSize:(CGSize)adSize
......
// //
...@@ -77,6 +77,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -77,6 +77,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUFullscreenVideoAdDelegate> delegate; @property (nonatomic, weak, nullable) id<BUFullscreenVideoAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Initializes video ad with slot id. Initializes video ad with slot id.
@param slotID : the unique identifier of video ad. @param slotID : the unique identifier of video ad.
......
// //
...@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUInterstitialAdDelegate> delegate; @property (nonatomic, weak, nullable) id<BUInterstitialAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Initializes interstitial ad. Initializes interstitial ad.
@param slotID : The unique identifier of interstitial ad. @param slotID : The unique identifier of interstitial ad.
......
// //
...@@ -69,7 +69,7 @@ typedef NS_ENUM(NSInteger, BUFeedADMode) { ...@@ -69,7 +69,7 @@ typedef NS_ENUM(NSInteger, BUFeedADMode) {
@property (nonatomic, assign) NSInteger videoDuration; @property (nonatomic, assign) NSInteger videoDuration;
/// media configuration parameters. /// media configuration parameters.
@property (nonatomic, strong) NSDictionary *mediaExt; @property (nonatomic, copy) NSDictionary *mediaExt;
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError * __autoreleasing *)error; - (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError * __autoreleasing *)error;
......
// //
...@@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, assign, readonly) BOOL isReady; @property (nonatomic, assign, readonly) BOOL isReady;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/* /*
required. required.
Root view controller for handling ad actions. Root view controller for handling ad actions.
......
// //
...@@ -67,15 +67,16 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -67,15 +67,16 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, assign, readonly) NSInteger interval; @property (nonatomic, assign, readonly) NSInteger interval;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithSlotID:(NSString *)slotID - (instancetype)initWithSlotID:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController rootViewController:(UIViewController *)rootViewController
imgSize:(BUSize * __nullable )expectSize
adSize:(CGSize)adsize adSize:(CGSize)adsize
IsSupportDeepLink:(BOOL)isSupportDeepLink; IsSupportDeepLink:(BOOL)isSupportDeepLink;
- (instancetype)initWithSlotID:(NSString *)slotID - (instancetype)initWithSlotID:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController rootViewController:(UIViewController *)rootViewController
imgSize:(BUSize * __nullable )expectSize
adSize:(CGSize)adsize adSize:(CGSize)adsize
IsSupportDeepLink:(BOOL)isSupportDeepLink IsSupportDeepLink:(BOOL)isSupportDeepLink
interval:(NSInteger)interval; interval:(NSInteger)interval;
......
// //
...@@ -83,6 +83,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -83,6 +83,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUNativeExpressFullscreenVideoAdDelegate> delegate; @property (nonatomic, weak, nullable) id<BUNativeExpressFullscreenVideoAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Initializes video ad with slot id. Initializes video ad with slot id.
@param slotID : the unique identifier of video ad. @param slotID : the unique identifier of video ad.
......
// //
...@@ -66,14 +66,16 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -66,14 +66,16 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Initializes interstitial ad. Initializes interstitial ad.
@param slotID : The unique identifier of interstitial ad. @param slotID : The unique identifier of interstitial ad.
@param expectSize : custom size of image, default 600px * 400px.
@param adsize : custom size of ad view. @param adsize : custom size of ad view.
@return BUInterstitialAd @return BUInterstitialAd
*/ */
- (instancetype)initWithSlotID:(NSString *)slotID imgSize:(BUSize * __nullable )expectSize adSize:(CGSize)adsize; - (instancetype)initWithSlotID:(NSString *)slotID adSize:(CGSize)adsize;
/** /**
Load interstitial ad datas. Load interstitial ad datas.
......
// //
...@@ -97,6 +97,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -97,6 +97,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) BURewardedVideoModel *rewardedVideoModel; @property (nonatomic, strong) BURewardedVideoModel *rewardedVideoModel;
@property (nonatomic, weak, nullable) id<BUNativeExpressRewardedVideoAdDelegate> delegate; @property (nonatomic, weak, nullable) id<BUNativeExpressRewardedVideoAdDelegate> delegate;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Whether material is effective. Whether material is effective.
Setted to YES when data is not empty and has not been displayed. Setted to YES when data is not empty and has not been displayed.
......
//
//
// BUNativeExpressSplashView.h
// BUAdSDK
//
// Copyright © 2019 bytedance. All rights reserved.
//
#import <UIKit/UIKit.h>
@class BUNativeExpressSplashView;
NS_ASSUME_NONNULL_BEGIN
@protocol BUNativeExpressSplashViewDelegate <NSObject>
/**
This method is called when splash ad material loaded successfully.
*/
- (void)nativeExpressSplashViewDidLoad:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when splash ad material failed to load.
@param error : the reason of error
*/
- (void)nativeExpressSplashView:(BUNativeExpressSplashView *)splashAdView didFailWithError:(NSError * _Nullable)error;
/**
This method is called when rendering a nativeExpressAdView successed.
*/
- (void)nativeExpressSplashViewRenderSuccess:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when a nativeExpressAdView failed to render.
@param error : the reason of error
*/
- (void)nativeExpressSplashViewRenderFail:(BUNativeExpressSplashView *)splashAdView error:(NSError * __nullable)error;
/**
This method is called when nativeExpressSplashAdView will be showing.
*/
- (void)nativeExpressSplashViewWillVisible:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when nativeExpressSplashAdView is clicked.
*/
- (void)nativeExpressSplashViewDidClick:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when nativeExpressSplashAdView's skip button is clicked.
*/
- (void)nativeExpressSplashViewDidClickSkip:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when nativeExpressSplashAdView closed.
*/
- (void)nativeExpressSplashViewDidClose:(BUNativeExpressSplashView *)splashAdView;
/**
This method is called when when video ad play completed or an error occurred.
*/
- (void)nativeExpressSplashViewFinishPlayDidPlayFinish:(BUNativeExpressSplashView *)splashView didFailWithError:(NSError *)error;
@end
@interface BUNativeExpressSplashView : UIView
/**
The delegate for receiving state change messages.
*/
@property (nonatomic, weak, nullable) id<BUNativeExpressSplashViewDelegate> delegate;
/**
Maximum allowable load timeout, default 3s, unit s.
*/
@property (nonatomic, assign) NSTimeInterval tolerateTimeout;
/**
Whether hide skip button, default NO.
If you hide the skip button, you need to customize the countdown.
*/
@property (nonatomic, assign) BOOL hideSkipButton;
/**
Whether the splash ad data has been loaded.
*/
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes native express splash ad with slot id and frame.
@param slotID : the unique identifier of splash ad
@param adSize : the adSize of native express splashAd view. It is recommended for the mobile phone screen.
@return BUNativeExpressSplashView
*/
- (instancetype)initWithSlotID:(NSString *)slotID adSize:(CGSize)adSize rootViewController:(UIViewController *)rootViewController;
/**
Load splash ad datas.
Start the countdown(@tolerateTimeout) as soon as you request datas.
*/
- (void)loadAdData;
/**
Remove splash view.
Stop the countdown as soon as you call this method.
移除开屏视图
一旦调用这个方法,倒计时将自动停止
*/
- (void)removeSplashView;
@end
NS_ASSUME_NONNULL_END
// //
...@@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithSlotID:(NSString *)slotID rewardedVideoModel:(BURewardedVideoModel *)model; - (instancetype)initWithSlotID:(NSString *)slotID rewardedVideoModel:(BURewardedVideoModel *)model;
- (void)loadAdData; - (void)loadAdData;
......
// //
...@@ -46,6 +46,8 @@ The unique identifier of splash ad. ...@@ -46,6 +46,8 @@ The unique identifier of splash ad.
*/ */
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; @property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/** /**
Initializes splash ad with slot id and frame. Initializes splash ad with slot id and frame.
......
// //
...@@ -23,6 +23,16 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,6 +23,16 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (CGFloat)currentPlayTime; - (CGFloat)currentPlayTime;
/**
Set video play when you support CustomMode
**/
- (void)play;
/**
Set video pause when you support CustomMode
**/
- (void)pause;
@end @end
@protocol BUVideoAdViewDelegate; @protocol BUVideoAdViewDelegate;
...@@ -31,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -31,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface BUVideoAdView : UIView<BUPlayerDelegate, BUVideoEngine> @interface BUVideoAdView : UIView<BUPlayerDelegate, BUVideoEngine>
@property (nonatomic, weak, nullable) id<BUVideoAdViewDelegate> delegate; @property (nonatomic, weak, nullable) id<BUVideoAdViewDelegate> delegate;
/**
/// required. Root view controller for handling ad actions. required. Root view controller for handling ad actions.
**/
@property (nonatomic, weak, readwrite) UIViewController *rootViewController; @property (nonatomic, weak, readwrite) UIViewController *rootViewController;
/** /**
...@@ -45,6 +56,13 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -45,6 +56,13 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, strong, readwrite, nullable) BUMaterialMeta *materialMeta; @property (nonatomic, strong, readwrite, nullable) BUMaterialMeta *materialMeta;
/**
Set your Video autoPlayMode when you support CustomMode
if support CustomMode , default autoplay Video
**/
@property (nonatomic, assign) BOOL supportAutoPlay;
- (instancetype)initWithMaterial:(BUMaterialMeta *)materialMeta; - (instancetype)initWithMaterial:(BUMaterialMeta *)materialMeta;
/** /**
......
//
//
// FSActionSheet.h
// FSActionSheet
//
// Created by Steven on 6/7/16.
// Copyright © 2016年 Steven. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "FSActionSheetItem.h"
#import "FSActionSheetConfig.h"
@class FSActionSheet;
@protocol FSActionSheetDelegate <NSObject>
@optional
- (void)FSActionSheet:(FSActionSheet *)actionSheet selectedIndex:(NSInteger)selectedIndex;
@end
@interface FSActionSheet : UIView
@property (nonatomic, weak) id<FSActionSheetDelegate> delegate; ///< 代理对象
@property (nonatomic, assign) FSContentAlignment contentAlignment; ///< 默认是FSContentAlignmentCenter.
@property (nonatomic, assign) BOOL hideOnTouchOutside; ///< 是否开启点击半透明层隐藏弹窗, 默认为YES.
/*! @author Steven
* @brief 单文本选项快速初始化
* @param title 标题
* @param delegate 代理
* @param cancelButtonTitle 取消按钮标题
* @param highlightedButtonTitle 高亮按钮标题
* @param otherButtonTitles 其他按钮标题集合
*/
- (instancetype)initWithTitle:(NSString *)title delegate:(id<FSActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle highlightedButtonTitle:(NSString *)highlightedButtonTitle otherButtonTitles:(NSArray<NSString *> *)otherButtonTitles;
/*! @author Steven
* @brief 在外部组装选项按钮item
* @param title 标题
* @param cancelTitle 取消按钮标题
* @param items 选项按钮item
*/
- (instancetype)initWithTitle:(NSString *)title cancelTitle:(NSString *)cancelTitle items:(NSArray<FSActionSheetItem *> *)items;
/*! @author Steven
* @brief 单展示, 不绑定block回调
*/
- (void)show;
/*! @author Steven
* @brief 展示并绑定block回调
* @param selectedHandler 选择选项按钮回调.
*/
- (void)showWithSelectedCompletion:(FSActionSheetHandler)selectedHandler;
@end
//
//
// FSActionSheetCell.h
// FSActionSheet
//
// Created by Steven on 6/7/16.
// Copyright © 2016年 Steven. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "FSActionSheetConfig.h"
@class FSActionSheetItem;
@interface FSActionSheetCell : UITableViewCell
@property (nonatomic, assign) FSContentAlignment contentAlignment;
@property (nonatomic, strong) FSActionSheetItem *item;
@property (nonatomic, assign) BOOL hideTopLine; ///< 是否隐藏顶部线条
@end
//
//
// FSActionSheetCell.m
// FSActionSheet
//
// Created by Steven on 6/7/16.
// Copyright © 2016年 Steven. All rights reserved.
//
#import "FSActionSheetCell.h"
#import "FSActionSheetItem.h"
@interface FSActionSheetCell ()
@property (nonatomic, strong) UIButton *titleButton;
@property (nonatomic, weak) UIView *topLine; ///< 顶部线条
@end
@implementation FSActionSheetCell
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if (highlighted) {
self.contentView.backgroundColor = FSColorWithString(FSActionSheetRowHighlightedColor);
} else {
[UIView animateWithDuration:0.25 animations:^{
self.contentView.backgroundColor = self.backgroundColor;
}];
}
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (!(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) return nil;
self.backgroundColor = FSColorWithString(FSActionSheetRowNormalColor);
self.contentView.backgroundColor = self.backgroundColor;
self.selectionStyle = UITableViewCellSelectionStyleNone;
_contentAlignment = FSContentAlignmentCenter;
[self setupSubviews];
return self;
}
- (void)setupSubviews {
_titleButton = [UIButton buttonWithType:UIButtonTypeSystem];
_titleButton.tintColor = FSColorWithString(FSActionSheetItemNormalColor);
_titleButton.titleLabel.font = [UIFont systemFontOfSize:FSActionSheetItemTitleFontSize];
_titleButton.userInteractionEnabled = NO;
_titleButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_titleButton];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_titleButton]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_titleButton)]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_titleButton]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_titleButton)]];
// 顶部线条
UIView *topLine = [[UIView alloc] init];
topLine.backgroundColor = FSColorWithString(FSActionSheetRowTopLineColor);
topLine.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:topLine];
self.topLine = topLine;
CGFloat lineHeight = 1/[UIScreen mainScreen].scale; ///< 线条高度
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[topLine]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(topLine)]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topLine(lineHeight)]" options:0 metrics:@{@"lineHeight":@(lineHeight)} views:NSDictionaryOfVariableBindings(topLine)]];
}
- (void)setItem:(FSActionSheetItem *)item {
_item = item;
// 前景色设置, 如果有自定义前景色则使用自定义的前景色, 否则使用预配置的颜色值.
UIColor *tintColor;
if (item.tintColor) {
tintColor = item.tintColor;
} else {
if (_item.type == FSActionSheetTypeNormal) {
tintColor = FSColorWithString(FSActionSheetItemNormalColor);
} else {
tintColor = FSColorWithString(FSActionSheetItemHighlightedColor);
}
}
_titleButton.tintColor = tintColor;
// 调整图片与标题的间距
_titleButton.imageEdgeInsets = UIEdgeInsetsMake(0, _item.image?-FSActionSheetItemContentSpacing/2:0,
_item.image?1:0, _item.image?FSActionSheetItemContentSpacing/2:0);
_titleButton.titleEdgeInsets = UIEdgeInsetsMake(_item.image?1:0, _item.image?FSActionSheetItemContentSpacing/2:0,
0, _item.image?-FSActionSheetItemContentSpacing/2:0);
// 设置图片与标题
[_titleButton setTitle:item.title forState:UIControlStateNormal];
[_titleButton setImage:item.image forState:UIControlStateNormal];
}
- (void)setContentAlignment:(FSContentAlignment)contentAlignment {
if (_contentAlignment == contentAlignment) return;
_contentAlignment = contentAlignment;
// 更新button的图片和标题Edge
[self updateButtonContentEdge];
// 设置内容偏移
switch (_contentAlignment) {
// 局左
case FSContentAlignmentLeft: {
_titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
_titleButton.contentEdgeInsets = UIEdgeInsetsMake(0, FSActionSheetDefaultMargin, 0, -FSActionSheetDefaultMargin);
break;
}
// 居中
case FSContentAlignmentCenter: {
_titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
_titleButton.contentEdgeInsets = UIEdgeInsetsZero;
break;
}
// 居右
case FSContentAlignmentRight: {
_titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
_titleButton.contentEdgeInsets = UIEdgeInsetsMake(0, -FSActionSheetDefaultMargin, 0, FSActionSheetDefaultMargin);
break;
}
}
}
// 更新button图片与标题的edge
- (void)updateButtonContentEdge {
if (!_item.image) return;
if (_contentAlignment == FSContentAlignmentRight) {
CGFloat titleWidth = [[_titleButton titleForState:UIControlStateNormal] sizeWithAttributes:@{NSFontAttributeName:_titleButton.titleLabel.font}].width;
_titleButton.imageEdgeInsets = UIEdgeInsetsMake(0, titleWidth, 1, -titleWidth);
_titleButton.titleEdgeInsets = UIEdgeInsetsMake(1, -_item.image.size.width-FSActionSheetItemContentSpacing,
0, _item.image.size.width+FSActionSheetItemContentSpacing);
} else {
_titleButton.imageEdgeInsets = UIEdgeInsetsMake(0, -FSActionSheetItemContentSpacing/2, 1, FSActionSheetItemContentSpacing/2);
_titleButton.titleEdgeInsets = UIEdgeInsetsMake(1, FSActionSheetItemContentSpacing/2, 0, -FSActionSheetItemContentSpacing/2);
}
}
- (void)setHideTopLine:(BOOL)hideTopLine {
_topLine.hidden = hideTopLine;
}
@end
//
//
// FSActionSheetConfig.h
// FSActionSheet
//
// Created by Steven on 6/7/16.
// Copyright © 2016 Steven. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
// 选择选项block回调
typedef void(^FSActionSheetHandler)(NSInteger selectedIndex);
// 选项类型枚举
typedef NS_ENUM(NSInteger, FSActionSheetType) {
FSActionSheetTypeNormal = 0,
FSActionSheetTypeHighlighted,
};
// 内容偏移枚举
typedef NS_ENUM(NSInteger, FSContentAlignment) {
FSContentAlignmentLeft = 0, ///< 内容紧靠左边
FSContentAlignmentCenter, ///< 内容居中
FSContentAlignmentRight, ///< 内容紧靠右边
};
// float
UIKIT_EXTERN CGFloat const FSActionSheetDefaultMargin; ///< 默认边距 (标题四边边距, 选项靠左或靠右时距离边缘的距离), default is 10.
UIKIT_EXTERN CGFloat const FSActionSheetContentMaxScale; ///< 弹窗内容高度与屏幕高度的默认比例, default is 0.65.
UIKIT_EXTERN CGFloat const FSActionSheetRowHeight; ///< 行高, default is 44.
UIKIT_EXTERN CGFloat const FSActionSheetTitleLineSpacing; ///< 标题行距, default is 2.5.
UIKIT_EXTERN CGFloat const FSActionSheetTitleKernSpacing; ///< 标题字距, default is 0.5.
UIKIT_EXTERN CGFloat const FSActionSheetItemTitleFontSize; ///< 选项文字字体大小, default is 16.
UIKIT_EXTERN CGFloat const FSActionSheetItemContentSpacing; ///< 选项图片和文字的间距, default is 5.
// color
UIKIT_EXTERN NSString * const FSActionSheetTitleColor; ///< 标题颜色, default is #888888
UIKIT_EXTERN NSString * const FSActionSheetBackColor; ///< 背景颜色, default is #E8E8ED
UIKIT_EXTERN NSString * const FSActionSheetRowNormalColor; ///< 单元格背景颜色, default is #FBFBFE
UIKIT_EXTERN NSString * const FSActionSheetRowHighlightedColor; ///< 选中高亮颜色, default is #F1F1F5
UIKIT_EXTERN NSString * const FSActionSheetRowTopLineColor; ///< 单元格顶部线条颜色, default is #D7D7D8
UIKIT_EXTERN NSString * const FSActionSheetItemNormalColor; ///< 选项默认颜色, default is #000000
UIKIT_EXTERN NSString * const FSActionSheetItemHighlightedColor; ///< 选项高亮颜色, default is #E64340
/*! @author Steven
* @brief 获取颜色
* @param aColorString 十六进制颜色字符串
*/
NS_INLINE UIColor *FSColorWithString(NSString *aColorString) {
if (aColorString.length == 0) {
return nil;
}
if ([aColorString hasPrefix:@"#"]) {
aColorString = [aColorString substringFromIndex:1];
}
if (aColorString.length == 6) {
int len = (int)aColorString.length/3;
unsigned int a[3];
for (int i=0; i<3; i++) {
NSRange range;
range.location = i*len;
range.length = len;
NSString *str = [aColorString substringWithRange:range];
[[NSScanner scannerWithString:str] scanHexInt:a+i];
if (len == 1) {
a[i] *= 17;
}
}
return [UIColor colorWithRed:a[0]/255.0f green:a[1]/255.0f blue:a[2]/255.0f alpha:1];
}
else if (aColorString.length == 8) {
int len = (int)aColorString.length/4;
unsigned int a[4];
for (int i=0; i<4; i++) {
NSRange range;
range.location = i*len;
range.length = len;
NSString *str = [aColorString substringWithRange:range];
[[NSScanner scannerWithString:str] scanHexInt:a+i];
if (len == 1) {
a[i] *= 17;
}
}
return [UIColor colorWithRed:a[0]/255.0f green:a[1]/255.0f blue:a[2]/255.0f alpha:a[3]/255.0f];
}
else if (aColorString.length <= 2) {
unsigned int gray;
[[NSScanner scannerWithString:aColorString] scanHexInt:&gray];
if (aColorString.length == 1)
{
gray *= 17;
}
return [UIColor colorWithWhite:gray/255.0f alpha:1];
}
return nil;
}
//
//
// FSActionSheetConfig.m
// FSActionSheet
//
// Created by Steven on 6/8/16.
// Copyright © 2016 Steven. All rights reserved.
//
#import "FSActionSheetConfig.h"
// float
CGFloat const FSActionSheetDefaultMargin = 10; ///< 默认边距 (标题四边边距, 选项靠左或靠右时距离边缘的距离)
CGFloat const FSActionSheetContentMaxScale = 0.65; ///< 弹窗内容高度与屏幕高度的默认比例
CGFloat const FSActionSheetRowHeight = 52; ///< 行高
CGFloat const FSActionSheetTitleLineSpacing = 2.5; ///< 标题行距
CGFloat const FSActionSheetTitleKernSpacing = 0.5; ///< 标题字距
CGFloat const FSActionSheetItemTitleFontSize = 16; ///< 选项文字字体大小, default is 16.
CGFloat const FSActionSheetItemContentSpacing = 5; ///< 选项图片和文字的间距
// color
NSString * const FSActionSheetTitleColor = @"#888888"; ///< 标题颜色
NSString * const FSActionSheetBackColor = @"#E8E8ED"; ///< 背景颜色
NSString * const FSActionSheetRowNormalColor = @"#FBFBFE"; ///< 单元格背景颜色
NSString * const FSActionSheetRowHighlightedColor = @"#F1F1F5"; ///< 选中高亮颜色
NSString * const FSActionSheetRowTopLineColor = @"#D7D7D8"; ///< 单元格顶部线条颜色
NSString * const FSActionSheetItemNormalColor = @"#000000"; ///< 选项默认颜色
NSString * const FSActionSheetItemHighlightedColor = @"#E64340"; ///< 选项高亮颜色
//
//
// FSActionSheetItem.h
// FSActionSheet
//
// Created by Steven on 16/5/11.
// Copyright © 2016年 Steven. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "FSActionSheetConfig.h"
@interface FSActionSheetItem : NSObject
@property (nonatomic, assign) FSActionSheetType type; ///< 选项类型, 有 默认 和 高亮 两种类型.
@property (nonatomic, strong) UIImage *image; ///< 选项图标, 建议image的size为 @2x: 46x46, @3x: 69x69.
@property (nonatomic, copy) NSString *title; ///< 选项标题
@property (nonatomic, strong) UIColor *tintColor; ///< 选项前景色, 如果设置了这个颜色的话, 则无论选项设置的图标是什么颜色都会被修改为当前设置的这个颜色,
///< 同时这个颜色也会是标题的文本颜色.
+ (instancetype)itemWithType:(FSActionSheetType)type image:(UIImage *)image title:(NSString *)title tintColor:(UIColor *)tintColor;
@end
/*! @author Steven
* @brief 单标题的选项
* @param type 类型
* @param title 标题
*/
NS_INLINE FSActionSheetItem *FSActionSheetTitleItemMake(FSActionSheetType type, NSString *title) {
return [FSActionSheetItem itemWithType:type image:nil title:title tintColor:nil];
}
/*! @author Steven
* @brief 标题和图标的选项
* @param type 类型
* @param image 图片
* @param title 标题
*/
NS_INLINE FSActionSheetItem *FSActionSheetTitleWithImageItemMake(FSActionSheetType type, UIImage *image, NSString *title) {
return [FSActionSheetItem itemWithType:type image:image title:title tintColor:nil];
}
/*! @author Steven
* @brief 单标题且自定义前景色的选项
* @param type 类型
* @param title 标题
* @param tintColor 自定义前景色
*/
NS_INLINE FSActionSheetItem *FSActionSheetTitleWithColorItemMake(FSActionSheetType type, NSString *title, UIColor *tintColor) {
return [FSActionSheetItem itemWithType:type image:nil title:title tintColor:tintColor];
}
/*! @author Steven
* @brief 标题和图片并且自定义前景色的选项
* @param type 类型
* @param title 标题
* @param image 图片
* @param tintColor 自定义前景色
*/
NS_INLINE FSActionSheetItem *FSActionSheetItemMake(FSActionSheetType type, UIImage *image, NSString *title, UIColor *tintColor) {
return [FSActionSheetItem itemWithType:type image:image title:title tintColor:tintColor];
}
//
//
// FSActionSheetItem.m
// FSActionSheet
//
// Created by Steven on 16/5/11.
// Copyright © 2016年 Steven. All rights reserved.
//
#import "FSActionSheetItem.h"
@implementation FSActionSheetItem
+ (instancetype)itemWithType:(FSActionSheetType)type image:(UIImage *)image title:(NSString *)title tintColor:(UIColor *)tintColor {
FSActionSheetItem *item = [[FSActionSheetItem alloc] init];
item.type = type;
item.image = image;
item.title = title;
item.tintColor = tintColor;
return item;
}
@end
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#import "ZXCustomAdView.h" #import "ZXCustomAdView.h"
#import "ZXScannerViewController.h" #import "ZXScannerViewController.h"
#import "ZXUMStatisticsManager.h" #import "ZXUMStatisticsManager.h"
#import "ZXLongPressWebView.h"
#define APPversion [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] #define APPversion [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]
#define kWidth [UIScreen mainScreen].bounds.size.width //屏幕宽度 #define kWidth [UIScreen mainScreen].bounds.size.width //屏幕宽度
...@@ -119,7 +119,6 @@ typedef enum ...@@ -119,7 +119,6 @@ typedef enum
#import "XDSReaderHeader.h" #import "XDSReaderHeader.h"
#import "DTCoreText.h" #import "DTCoreText.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <CoreText/CoreText.h> #import <CoreText/CoreText.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment