Commit b1790d27 by 刘卓鑫

新增长按识别二维码

parent 1634812e
......@@ -3,86 +3,4 @@
uuid = "0B73904D-2C2A-44A2-88D3-64B4C86B59B2"
type = "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>
......@@ -81,8 +81,6 @@
//设置根视图
[self createWindow];
//token登录
[self tokenLogin];
//注册穿山甲
[BUADTool setupBUAdSDK];
//开屏广告
......@@ -91,7 +89,10 @@
@strongify(self);
[self createBaiduLauchAd];
}];
//token登录
dispatch_async(dispatch_get_main_queue(), ^{
[self tokenLogin];
});
//版本检测
[self checkVersion];
......@@ -105,6 +106,7 @@
//防止蓝牙洗浴后台运行被系统中断
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(ccc) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
NSLog(@"%@", CachePath);
return YES;
}
#pragma mark - BaiduMobAdViewDelegate
......@@ -128,6 +130,7 @@
-(void) failedDisplayAd:(BaiduMobFailReason) reason;
{
NSLog(@"delegate: failedDisplayAd %d", reason);
[self.splashView removeFromSuperview];
}
- (void)didAdImpressed {
......@@ -171,6 +174,7 @@
*/
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error {
NSLog(@"穿山甲开屏广告加载失败");
[splashAd removeFromSuperview];
}
- (void) ccc {
//CK900100
......@@ -371,7 +375,7 @@
[[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 YES;
......@@ -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 YES;
......@@ -416,6 +420,10 @@
SendAuthResp *r = (SendAuthResp *)resp;
[[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 {
[[NSNotificationCenter defaultCenter] postNotificationName:kWX_PAY_RESULT object:@(resp.errCode)];
}
......@@ -550,10 +558,6 @@
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification NS_AVAILABLE_IOS(12.0) {
}
#pragma mark - 点击推送 跳转 反馈/未支付订单
- (void) jumpNotPayView:(NSDictionary *) userInfo {
if (userInfo[@"CODE"] == nil || [userInfo[@"CODE"] isKindOfClass:[NSNull class]]) {
......
//
//
......@@ -57,6 +57,7 @@
*/
- (void)splashAd:(BUSplashAdView *)splashAd didFailWithError:(NSError * _Nullable)error {
NSLog(@"穿山甲开屏广告加载失败");
[splashAd removeFromSuperview];
}
- (void) loadBannerAdWithController:(UIViewController *) viewController superView:(UIView *) superView isFirstPage:(BOOL) isFirst {
......@@ -64,7 +65,8 @@
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90;
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;
[superView addSubview:self.bannerView];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
......@@ -84,7 +86,7 @@ bottomMargin:(CGFloat) bottomMargin {
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90;
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;
[superView insertSubview:self.bannerView atIndex:0];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
......@@ -100,7 +102,7 @@ bottomMargin:(CGFloat) bottomMargin {
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90;
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;
[superView insertSubview:self.bannerView atIndex:0];
[self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
......
//
//
......@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZXAdTool : NSObject
//开始获取开屏广告配置
+ (void) startLauchAdIsBaiduAd:(dispatch_block_t) baiduAd;
@end
......
//
//
......@@ -47,6 +47,8 @@ static NSString *kFailurMsg = @"数据加载失败,请检查一下当前网络
/*微信授权通知*/
#define kWX_AUTH_RESULT @"wxaouthResult"
/*微信小程序通知*/
#define kWX_Min_RESULT @"wxminiProgremResult"
/*微信支付结果通知*/
#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 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil];
// //测试按钮
//// //测试按钮
// UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)];
// [self.view addSubview:btn];
// btn.backgroundColor = [UIColor orangeColor];
// [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
// ZXTaskViewController *vc = [[NSClassFromString(@"ZXTaskViewController") alloc] init];
// [self.navigationController pushViewController:vc animated:YES];
//// [kApplication openURL:[NSURL URLWithString:@"weixin://scanqrcode"]];
//
// }];
//
if ([[kUserDefaults objectForKey:@"kAPP_IS_OPENB_TASK"] isEqualToString:@"yes"]) {
//查看任务相关内容
[self tashShow];
}
}
- (void) tashShow {
@weakify(self);
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:[NSString stringWithFormat:@"%@/dcxy/api/tasks/homePage", [kUserDefaults objectForKey:@"Task"]] para:nil completed:^(CommonModel *common, NSString *error) {
......@@ -132,6 +132,7 @@
self.tabBarController.tabBar.hidden = NO;
self.navigationController.navigationBar.hidden = YES;
[UIApplication sharedApplication].statusBarHidden = NO;
}
#pragma mark - 收到支付完成的通知
- (void) payCompleted {
......@@ -152,8 +153,7 @@
[self changeIconAction];
};
[self.view addSubview:self.naHeader];
//阿里妈妈测试代码
[ZXTool alimamaTest];
}
- (void)viewWillAppear:(BOOL)animated {
......
//
//
......@@ -10,9 +10,12 @@
#import <WebKit/WebKit.h>
#import "ZXHomePageService.h"
#import "ZXHomePageAnnouce.h"
@interface ZXHomePageWebViewController ()<WKNavigationDelegate, WKUIDelegate>
/** */
@property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) ZXLongPressWebView *webView;
@end
@implementation ZXHomePageWebViewController
......@@ -39,7 +42,7 @@
}
- (WKWebView *)webView {
if (!_webView) {
_webView = [[WKWebView alloc] init];
_webView = [[ZXLongPressWebView alloc] init];
_webView.backgroundColor = [UIColor whiteColor];
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
......@@ -57,6 +60,8 @@
self.titleStr = self.webView.title;
}
[ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
}
#pragma mark - ========== 加载失败 ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
......@@ -199,4 +204,6 @@
}];
}
@end
//
//
......@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ZXLongPressTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageBannerCell : UITableViewCell
@interface ZXHomePageBannerCell : ZXLongPressTableViewCell
@property (nonatomic, strong) NSArray *banners;
/*点击了外部功能*/
@property (nonatomic, copy) clickOtherOperation clickOther;
......
//
//
......@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ZXLongPressTableViewCell.h"
@class ZXHomeSecondChildInfo;
NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageSingleCell : UITableViewCell
@interface ZXHomePageSingleCell : ZXLongPressTableViewCell
/** child */
......
//
//
......@@ -6,11 +6,11 @@
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ZXLongPressTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^clickOtherOperation)(id item);
@interface ZXHomePageWindowCell : UITableViewCell
@interface ZXHomePageWindowCell : ZXLongPressTableViewCell
/** */
@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 @@
@interface ZXHomePageAnnounceView()<UIScrollViewDelegate, WKNavigationDelegate, WKUIDelegate>
@property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) ZXLongPressWebView *webView;
@property (nonatomic, strong) JXLayoutButton *agreedBtn;
......@@ -67,7 +67,7 @@
[self.agreedBtn addTarget:self action:@selector(notAlert:) forControlEvents:UIControlEventTouchUpInside];
self.webView = [[WKWebView alloc] init];
self.webView = [[ZXLongPressWebView alloc] init];
[bgView addSubview:self.webView];
self.webView.UIDelegate = self;
......@@ -111,7 +111,8 @@
}
}];
[ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
}
#pragma mark - ==========确定事件==========
- (void) okAction:(UIButton *) sender {
......
//
//
......@@ -610,9 +610,9 @@
[self.tempData addObject:[result dataUsingEncoding:NSUTF8StringEncoding]];
} else {
//发送给蓝牙
if (data.length > 100) {
return;
}
// if (data.length > 100) {
// return;
// }
[self.tempData addObject:data];
}
}
......
//
//
......@@ -905,9 +905,9 @@
NSLog(@"=============收到服务器返回的设备号");
} else {
//发送给蓝牙
if (data.length > 100) {
return;
}
// if (data.length > 100) {
// return;
// }
[self.tempData addObject:data];
}
}
......
//
//
......@@ -14,6 +14,7 @@
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "ZXLoginAnimationView.h"
#import "ZXOauthHasDCAccountViewController.h"
#import "XieYIViewController.h"
@interface ZXLoginViewController ()
/** 用户名 */
......@@ -49,9 +50,35 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification 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 - 是否需要展示第三方登录按钮
- (void) isNeedShowWXLogin {
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/app/customer/login/initdata", [kUserDefaults objectForKey:@"NEW_PAY"]] para:nil completed:^(CommonModel *common, NSString *error) {
......@@ -103,17 +130,7 @@
make.centerY.equalTo(label3.mas_centerY);
}];
[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 {
......
//
//
......@@ -12,6 +12,8 @@
@interface XieYIViewController ()<WKNavigationDelegate,WKUIDelegate>
@property(nonatomic,strong)WKWebView *webView;
@property (strong, nonatomic) XieYiModel * xieyiModel;
/** */
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation XieYIViewController
......@@ -21,6 +23,8 @@
WKWebViewConfiguration *config = [WKWebViewConfiguration new];
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.UIDelegate = self;
_webView.navigationDelegate = self;
}
return _webView;
}
......@@ -77,6 +81,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
self.navigationController.navigationBar.hidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -104,8 +109,11 @@
[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.navigationItem.titleView = titleLabel;
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 = self.titleLabel;
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
// self.titleLabel.text = webView.title;
}
- (void)backBtnFuc{
[SVProgressHUD dismiss];
......
//
//
......@@ -9,6 +9,7 @@
#import "AboutUs.h"
#import <WebKit/WebKit.h>
#import "AboutUsModel.h"
#import "XieYIViewController.h"
#import "enlargeClickRegionBtn.h"
@interface AboutUs ()<WKNavigationDelegate,WKUIDelegate,UIGestureRecognizerDelegate>
@property (nonatomic,strong) WKWebView* webView;
......@@ -18,7 +19,7 @@
@implementation AboutUs
- (void)dealloc{
[self removeNotificationAndKVO];
[self.webView removeObserver:self forKeyPath:@"loading"];
[self.webView removeObserver:self forKeyPath:@"estimatedProgress"];
......@@ -44,10 +45,10 @@
if ([keyPath isEqualToString:@"isLoaded"]) {
NSString * url =self.aboutModel.H5Url;
NSURL * webUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:webUrl];
[self.webView loadRequest:request];
[self.view addSubview:self.webView];
NSURL * webUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:webUrl];
[self.webView loadRequest:request];
}
else{
......@@ -64,7 +65,7 @@
[SVProgressHUD dismiss];
}
}
}
......@@ -75,7 +76,7 @@
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.scrollView.showsVerticalScrollIndicator=NO;
[self.view addSubview:_webView];
}
return _webView;
}
......@@ -90,23 +91,41 @@
[self registNotificationAndKVO];
[_aboutModel aboutUs];
[SVProgressHUD show];
if (self.isFromSimple) {
[self createNabar];
} else {
[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 - ========== 创建导航栏 ==========
- (void) createNabar {
UIImageView *nabar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kTopHeight)];
nabar.backgroundColor = [UIColor whiteColor];
nabar.userInteractionEnabled = YES;
nabar.image = kToppicBgImage;
[self.view addSubview:nabar];
UILabel *naTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenWidth, kNavBarHeight)];
naTitle.backgroundColor = [UIColor clearColor];
naTitle.textAlignment = NSTextAlignmentCenter;
......@@ -125,7 +144,7 @@
}];
__weak typeof(self) weakSelf = self;
[[back rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
}
......@@ -140,7 +159,7 @@
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
if (self.isFromSimple) {
} else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
......@@ -165,15 +184,15 @@
backgroundColor:[UIColor clearColor] font:[UIFont boldSystemFontOfSize:MC_NAVBAR_TITLE_FONT_SIZE] textColor:[UIColor colorWithHexString:@"#f3f3f3"] textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByWordWrapping];
self.navigationItem.titleView = titleLabel;
}
/*
返回
*/
*/
-(void)backBtnFuc
{
[SVProgressHUD dismiss];
if (self.webView.canGoBack) {
[self.webView goBack];
......@@ -186,7 +205,7 @@
}
}
}
- (void)didReceiveMemoryWarning
{
......
//
//
......@@ -808,6 +808,12 @@ heightForFooterInSection:(NSInteger)section {
m.topic = @"京东支付";
m.payType = @"4";
[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) {
......
//
//
......@@ -15,7 +15,8 @@
UIButton *confirmBtn;
NSInteger payTypeValue;//支付方式对应的类型
}
/** */
@property (nonatomic, copy) NSString *wxCode;
@end
@implementation ZXConfirmPayViewController
......@@ -92,6 +93,10 @@
payStyleLabel.text = @"京东支付";
payTypeValue = 4;
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];
......@@ -123,12 +128,18 @@
self.navigationController.navigationBar.hidden = YES;
[[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(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wechatMiniResult:) name:kWX_Min_RESULT object:nil];
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBar.hidden = NO;
[[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_AUTH_RESULT object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_Min_RESULT object:nil];
}
#pragma mark - ========== 创建导航栏 ==========
- (void) createNabar {
......@@ -162,7 +173,24 @@
}
- (void) confirmBtnFuc {
[self requestPay:self.rechargeId payType:payTypeValue];
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];
}
}
#pragma mark - ========== 创建充值订单 ==========
......@@ -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
//
//
// 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);
+ (NSString *) formatJumpUrl:(NSString *) jumpUrl;
+(void) alimamaTest;
//ip
+ (NSString*)getCurentLocalIP;
......
//
//
......@@ -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地址
+ (NSString*)getCurentLocalIP{
    NSString*address =nil;
    struct ifaddrs*interfaces =NULL;
    struct ifaddrs*temp_addr =NULL;
    int success =0;
NSString*address =nil;
    // 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"]) {
                }
            }
            temp_addr = temp_addr->ifa_next;
        }
    }
    // Free memory
// 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;
}
}
// Free memory
    freeifaddrs(interfaces);
freeifaddrs(interfaces);
    return address;
return address;
}
......
/*
/*
......@@ -18,13 +18,18 @@
"Replay" = "Click to replay";
"Continue" = "Continue to play";
"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";
"Download" = "Download";
"LoadFailure" = "Failed to load, and click to try again";
"GetRewardAfterWatching" = "Get reward after watching the full video";
"GiveUpReward" = "Give up reward";
"ContinueWatching" = "Continue watching";
"CanbeTurnedOffAfter" = "can be turned off after %ds";
"CanbeTurnedOffAfter" = "Skip after %ds";
"Get" = "Get";
"View" = "View";
// Icon
/*
/*
......@@ -18,6 +18,11 @@
"Replay" = "リプレイ";
"Continue" = "再生し続ける";
"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" = "詳細を見る";
"Download" = "download";
"LoadFailure" = "ロードに失敗しました。クリックして再度お試しください";
......
/*
/*
......@@ -18,6 +18,11 @@
"Replay" = "点击重播";
"Continue" = "继续播放";
"Skip" = "跳过";
"Feedback" = "反馈";
"FeedbackStr1" = "感谢您的反馈!";
"FeedbackStr2" = "我们将为您带来更优质的广告体验";
"FeedbackStr3" = "您已提交过反馈!";
"FeedbackStr4" = "请勿反复提交";
"ViewNow" = "立即查看";
"Download" = "立即下载";
"LoadFailure" = "加载失败,点击重试";
......
//
//
......@@ -34,6 +34,7 @@
#import <BUAdSDK/BUNativeExpressInterstitialAd.h>
#import <BUAdSDK/BUNativeExpressRewardedVideoAd.h>
#import <BUAdSDK/BUNativeExpressFullscreenVideoAd.h>
#import <BUAdSDK/BUNativeExpressSplashView.h>
/// banner ads
#import <BUAdSDK/BUBannerAdView.h>
......
//
//
......@@ -10,10 +10,10 @@
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, BUUserGender) {
BUUserGenderUnknown,
BUUserGenderMan,
BUUserGenderWoman,
typedef NS_ENUM(NSInteger, BUOfflineType) {
BUOfflineTypeNone, // Do not set offline
BUOfflineTypeProtocol, // Offline dependence NSURLProtcol
BUOfflineTypeWebview, // Offline dependence WKWebview
};
typedef NS_ENUM(NSInteger, BUAdSDKLogLevel) {
......
//
//
......@@ -17,34 +17,35 @@
@param appID : the unique identifier of the App
*/
+ (void)setAppID:(NSString *)appID;
/**
Configure development mode.
@param level : default BUAdSDKLogLevelNone
*/
+ (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.
* @params Coppa 0 adult, 1 child
*/
+ (void)setCoppa:(NSUInteger)Coppa;
/// Set the user's keywords, such as interests and hobbies, etc.
/// Must obtain the consent of the user before incoming.
+ (void)setUserKeywords:(NSString *)keywords;
/// set additional user information.
+ (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;
/// Solve the problem when your WKWebview post message empty,default is BUOfflineTypeWebview
+ (void)setOfflineType:(BUOfflineType)type;
/// get appID
+ (NSString *)appID;
/// get isPaidApp
+ (BOOL)isPaidApp;
@end
......
//
//
......@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, strong, readonly, nonnull) UIButton *dislikeButton;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithIdentifier:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController
adSize:(CGSize)adSize
......
//
//
......@@ -77,6 +77,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUFullscreenVideoAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes video ad with slot id.
@param slotID : the unique identifier of video ad.
......
//
//
......@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUInterstitialAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes interstitial ad.
@param slotID : The unique identifier of interstitial ad.
......
//
//
......@@ -69,7 +69,7 @@ typedef NS_ENUM(NSInteger, BUFeedADMode) {
@property (nonatomic, assign) NSInteger videoDuration;
/// media configuration parameters.
@property (nonatomic, strong) NSDictionary *mediaExt;
@property (nonatomic, copy) NSDictionary *mediaExt;
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError * __autoreleasing *)error;
......
//
//
......@@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, assign, readonly) BOOL isReady;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/*
required.
Root view controller for handling ad actions.
......
//
//
......@@ -67,15 +67,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, assign, readonly) NSInteger interval;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithSlotID:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController
imgSize:(BUSize * __nullable )expectSize
adSize:(CGSize)adsize
IsSupportDeepLink:(BOOL)isSupportDeepLink;
- (instancetype)initWithSlotID:(NSString *)slotID
rootViewController:(UIViewController *)rootViewController
imgSize:(BUSize * __nullable )expectSize
adSize:(CGSize)adsize
IsSupportDeepLink:(BOOL)isSupportDeepLink
interval:(NSInteger)interval;
......
//
//
......@@ -83,6 +83,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id<BUNativeExpressFullscreenVideoAdDelegate> delegate;
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes video ad with slot id.
@param slotID : the unique identifier of video ad.
......
//
//
......@@ -66,14 +66,16 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes 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.
@return BUInterstitialAd
*/
- (instancetype)initWithSlotID:(NSString *)slotID imgSize:(BUSize * __nullable )expectSize adSize:(CGSize)adsize;
- (instancetype)initWithSlotID:(NSString *)slotID adSize:(CGSize)adsize;
/**
Load interstitial ad datas.
......
//
//
......@@ -97,6 +97,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) BURewardedVideoModel *rewardedVideoModel;
@property (nonatomic, weak, nullable) id<BUNativeExpressRewardedVideoAdDelegate> delegate;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Whether material is effective.
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
*/
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
- (instancetype)initWithSlotID:(NSString *)slotID rewardedVideoModel:(BURewardedVideoModel *)model;
- (void)loadAdData;
......
//
//
......@@ -46,6 +46,8 @@ The unique identifier of splash ad.
*/
@property (nonatomic, getter=isAdValid, readonly) BOOL adValid;
/// media configuration parameters.
@property (nonatomic, copy, readonly) NSDictionary *mediaExt;
/**
Initializes splash ad with slot id and frame.
......
//
//
......@@ -23,6 +23,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (CGFloat)currentPlayTime;
/**
Set video play when you support CustomMode
**/
- (void)play;
/**
Set video pause when you support CustomMode
**/
- (void)pause;
@end
@protocol BUVideoAdViewDelegate;
......@@ -31,8 +41,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface BUVideoAdView : UIView<BUPlayerDelegate, BUVideoEngine>
@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;
/**
......@@ -45,6 +56,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
@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;
/**
......
//
//
// 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 @@
#import "ZXCustomAdView.h"
#import "ZXScannerViewController.h"
#import "ZXUMStatisticsManager.h"
#import "ZXLongPressWebView.h"
#define APPversion [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]
#define kWidth [UIScreen mainScreen].bounds.size.width //屏幕宽度
......@@ -119,7 +119,6 @@ typedef enum
#import "XDSReaderHeader.h"
#import "DTCoreText.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.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