@@ -1229,16 +1229,36 @@ + (TXCustomModel *)buildVideoOrGifBackgroundModel:(NSDictionary *)viewConfig
12291229 style : (PNSBuildModelStyle)style
12301230 selector : (SEL )selector {
12311231 PNSBackgroundView *backgroundView = [[PNSBackgroundView alloc ] init ];
1232+ return [self buildModelOption: viewConfig target: target style: style background: backgroundView selector: selector];
1233+ }
1234+
1235+ #pragma mark - 公共配置
1236+ + (TXCustomModel *)buildModelOption : (NSDictionary *)viewConfig
1237+ target : (id )target
1238+ style : (PNSBuildModelStyle)style
1239+ background : (PNSBackgroundView*)backgroundView
1240+ selector : (SEL )selector {
1241+ TXCustomModel *model = [[TXCustomModel alloc ] init ];
1242+
12321243 // 判断背景类型
12331244 NSURL *backgroundUrl = [NSURL fileURLWithPath: [self changeUriToPath: [viewConfig stringValueForKey: @" backgroundPath" defaultValue: nil ]]];
1234- if (PNSBuildModelStyleGifBackground == style) {
1235- backgroundView.gifUrl = backgroundUrl;
1245+ if (backgroundView != nil && backgroundUrl != nil ) {
1246+ if (PNSBuildModelStyleGifBackground == style) {
1247+ backgroundView.gifUrl = backgroundUrl;
1248+ } else {
1249+ backgroundView.videoUrl = backgroundUrl;
1250+ }
1251+ [backgroundView show ];
12361252 } else {
1237- backgroundView.videoUrl = backgroundUrl;
1253+ NSString * backgroundColor = [viewConfig stringValueForKey: @" backgroundColor" defaultValue: nil ];
1254+ if (![backgroundColor isEqual: nil ]) {
1255+ model.backgroundColor = [self getColor: backgroundColor];
1256+ }
1257+ NSString * backgroundImagePath = [viewConfig stringValueForKey: @" backgroundPath" defaultValue: nil ];
1258+ if (![backgroundImagePath isEqual: nil ]) {
1259+ model.backgroundImage = [self changeUriPathToImage: backgroundImagePath];
1260+ }
12381261 }
1239- [backgroundView show ];
1240-
1241- TXCustomModel *model = [[TXCustomModel alloc ] init ];
12421262
12431263 // / 返回按钮 END
12441264 // / 1、状态栏 START
@@ -1435,7 +1455,9 @@ + (TXCustomModel *)buildVideoOrGifBackgroundModel:(NSDictionary *)viewConfig
14351455 }
14361456 // / 添加第三方图标
14371457 model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
1438- [superCustomView addSubview: backgroundView];
1458+ if (backgroundView != nil && backgroundUrl != nil ) {
1459+ [superCustomView addSubview: backgroundView];
1460+ }
14391461 for (int i = 0 ; i < customArrayView.count ; i++) {
14401462 [superCustomView addSubview: customArrayView[i]];
14411463 }
@@ -1453,7 +1475,9 @@ + (TXCustomModel *)buildVideoOrGifBackgroundModel:(NSDictionary *)viewConfig
14531475 CGRect changeBtnFrame, // / 切换到其他的参数
14541476 CGRect privacyFrame // / 协议区域的参数
14551477 ) {
1456- backgroundView.frame = CGRectMake (0 , -CGRectGetMaxY (navFrame), contentViewFrame.size .width , contentViewFrame.size .height );
1478+ if (backgroundView != nil && backgroundUrl != nil ) {
1479+ backgroundView.frame = CGRectMake (0 , -CGRectGetMaxY (navFrame), contentViewFrame.size .width , contentViewFrame.size .height );
1480+ }
14571481
14581482 NSUInteger count = customArrayView.count ;
14591483 NSInteger contentWidth = screenSize.width ;
@@ -1464,25 +1488,6 @@ + (TXCustomModel *)buildVideoOrGifBackgroundModel:(NSDictionary *)viewConfig
14641488 }
14651489 };
14661490 }
1467- } else {
1468- model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
1469- [superCustomView addSubview: backgroundView];
1470- };
1471-
1472- model.customViewLayoutBlock = ^(
1473- CGSize screenSize, // / 全屏参数
1474- CGRect contentViewFrame, // / contentView参数
1475- CGRect navFrame, // / 导航参数
1476- CGRect titleBarFrame, // / title参数
1477- CGRect logoFrame, // / logo区域参数
1478- CGRect sloganFrame, // / slogan参数
1479- CGRect numberFrame, // / 号码处参数
1480- CGRect loginFrame, // / 登录按钮处的参数
1481- CGRect changeBtnFrame, // / 切换到其他的参数
1482- CGRect privacyFrame // / 协议区域的参数
1483- ) {
1484- backgroundView.frame = CGRectMake (0 , -CGRectGetMaxY (navFrame), contentViewFrame.size .width , contentViewFrame.size .height );
1485- };
14861491 }
14871492 // / 8、第三方 END
14881493
@@ -1582,14 +1587,29 @@ + (TXCustomModel *)buildVideoOrGifBackgroundModel:(NSDictionary *)viewConfig
15821587 }
15831588 // / 9、协议 END
15841589
1585- model.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
1586- // model.navIsHidden = YES;
1587- model.navBackImage = [UIImage imageNamed: @" icon_nav_back_light" ];
1588- model.navColor = [UIColor clearColor ];
1589- model.navTitle = [[NSAttributedString alloc ] init ];
1590- model.numberColor = [UIColor whiteColor ];
1590+ if (backgroundView != nil ) {
1591+ model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
1592+ [superCustomView addSubview: backgroundView];
1593+ };
15911594
1592- return model;
1595+ model.customViewLayoutBlock = ^(
1596+ CGSize screenSize, // / 全屏参数
1597+ CGRect contentViewFrame, // / contentView参数
1598+ CGRect navFrame, // / 导航参数
1599+ CGRect titleBarFrame, // / title参数
1600+ CGRect logoFrame, // / logo区域参数
1601+ CGRect sloganFrame, // / slogan参数
1602+ CGRect numberFrame, // / 号码处参数
1603+ CGRect loginFrame, // / 登录按钮处的参数
1604+ CGRect changeBtnFrame, // / 切换到其他的参数
1605+ CGRect privacyFrame // / 协议区域的参数
1606+ ) {
1607+ backgroundView.frame = CGRectMake (0 , -CGRectGetMaxY (navFrame), contentViewFrame.size .width , contentViewFrame.size .height );
1608+ };
1609+ }
1610+ // / 屏幕方向
1611+ model.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
1612+ return model;
15931613}
15941614
15951615#pragma mark - DIY 动画
0 commit comments