Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CCVideo
VOD_iOS_SDK
Commits
b4c4618b
Commit
b4c4618b
authored
Jun 23, 2022
by
guow
Browse files
4.16.0
parent
d021faa7
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
437 additions
and
24 deletions
+437
-24
.DS_Store
.DS_Store
+0
-0
Demo/Demo.xcodeproj/project.pbxproj
Demo/Demo.xcodeproj/project.pbxproj
+14
-0
Demo/Demo/Classes/DWLocalPlayViewController.m
Demo/Demo/Classes/DWLocalPlayViewController.m
+1
-1
Demo/Demo/Classes/DWVodPlayViewController.m
Demo/Demo/Classes/DWVodPlayViewController.m
+14
-10
Demo/Demo/Classes/View/Player/DWVodPlayerView.m
Demo/Demo/Classes/View/Player/DWVodPlayerView.m
+86
-9
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.h
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.h
+19
-0
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.m
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.m
+245
-0
Demo/Demo/Images.xcassets/Contents.json
Demo/Demo/Images.xcassets/Contents.json
+3
-3
Demo/Demo/Images.xcassets/Sigin/Contents.json
Demo/Demo/Images.xcassets/Sigin/Contents.json
+6
-0
Demo/Demo/Images.xcassets/Sigin/sigin_icon.imageset/Contents.json
...o/Images.xcassets/Sigin/sigin_icon.imageset/Contents.json
+22
-0
Demo/Demo/Images.xcassets/Sigin/sigin_icon.imageset/sigin_icon@2x.png
...ages.xcassets/Sigin/sigin_icon.imageset/sigin_icon@2x.png
+0
-0
Demo/Demo/Images.xcassets/Sigin/sigin_icon.imageset/sigin_icon@3x.png
...ages.xcassets/Sigin/sigin_icon.imageset/sigin_icon@3x.png
+0
-0
Demo/Demo/Images.xcassets/Sigin/sign_bgView_icon.imageset/Contents.json
...es.xcassets/Sigin/sign_bgView_icon.imageset/Contents.json
+22
-0
Demo/Demo/Images.xcassets/Sigin/sign_bgView_icon.imageset/sign_bgView_icon@2x.png
...s/Sigin/sign_bgView_icon.imageset/sign_bgView_icon@2x.png
+0
-0
Demo/Demo/Images.xcassets/Sigin/sign_bgView_icon.imageset/sign_bgView_icon@3x.png
...s/Sigin/sign_bgView_icon.imageset/sign_bgView_icon@3x.png
+0
-0
Demo/Demo/SDK/CCVodSDK.framework/CCVodSDK
Demo/Demo/SDK/CCVodSDK.framework/CCVodSDK
+0
-0
Demo/Demo/SDK/CCVodSDK.framework/Headers/CCVodSDK.h
Demo/Demo/SDK/CCVodSDK.framework/Headers/CCVodSDK.h
+1
-1
Demo/Demo/SDK/CCVodSDK.framework/Headers/DWDownloadModel.h
Demo/Demo/SDK/CCVodSDK.framework/Headers/DWDownloadModel.h
+2
-0
Demo/Demo/SDK/CCVodSDK.framework/Headers/DWVodVideoModel.h
Demo/Demo/SDK/CCVodSDK.framework/Headers/DWVodVideoModel.h
+2
-0
Demo/Demo/SDK/CCVodSDK.framework/Info.plist
Demo/Demo/SDK/CCVodSDK.framework/Info.plist
+0
-0
No files found.
.DS_Store
View file @
b4c4618b
No preview for this file type
Demo/Demo.xcodeproj/project.pbxproj
View file @
b4c4618b
...
...
@@ -409,6 +409,7 @@
B57CC7BE18E2E575001A1696
/* CoreLocation.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B57CC7BD18E2E575001A1696
/* CoreLocation.framework */
;
};
B57CC7C018E2E581001A1696
/* AVFoundation.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B57CC7BF18E2E581001A1696
/* AVFoundation.framework */
;
};
B88562A41DED1AC8008D1763
/* SystemConfiguration.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B88562A31DED1AC8008D1763
/* SystemConfiguration.framework */
;
};
C4F90D572864560B008A1E38
/* HDSSiginVIew.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C4F90D552864560B008A1E38
/* HDSSiginVIew.m */
;
};
DD25727D24F79DED00D9BB55
/* icon_exercises_close@3x.png in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
DD25727B24F79DED00D9BB55
/* icon_exercises_close@3x.png */
;
};
DD25727E24F79DED00D9BB55
/* icon_exercises_close@2x.png in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
DD25727C24F79DED00D9BB55
/* icon_exercises_close@2x.png */
;
};
DD383817264E5844006A48EE
/* vrlibraw.bundle in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
DD383815264E5844006A48EE
/* vrlibraw.bundle */
;
};
...
...
@@ -1010,6 +1011,8 @@
B57CC7BD18E2E575001A1696
/* CoreLocation.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
CoreLocation.framework
;
path
=
System/Library/Frameworks/CoreLocation.framework
;
sourceTree
=
SDKROOT
;
};
B57CC7BF18E2E581001A1696
/* AVFoundation.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
AVFoundation.framework
;
path
=
System/Library/Frameworks/AVFoundation.framework
;
sourceTree
=
SDKROOT
;
};
B88562A31DED1AC8008D1763
/* SystemConfiguration.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
SystemConfiguration.framework
;
path
=
System/Library/Frameworks/SystemConfiguration.framework
;
sourceTree
=
SDKROOT
;
};
C4F90D552864560B008A1E38
/* HDSSiginVIew.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
HDSSiginVIew.m
;
sourceTree
=
"<group>"
;
};
C4F90D562864560B008A1E38
/* HDSSiginVIew.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
HDSSiginVIew.h
;
sourceTree
=
"<group>"
;
};
DD25727B24F79DED00D9BB55
/* icon_exercises_close@3x.png */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.png
;
path
=
"icon_exercises_close@3x.png"
;
sourceTree
=
"<group>"
;
};
DD25727C24F79DED00D9BB55
/* icon_exercises_close@2x.png */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.png
;
path
=
"icon_exercises_close@2x.png"
;
sourceTree
=
"<group>"
;
};
DD383811264E5839006A48EE
/* CCVodSDK.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
path
=
CCVodSDK.framework
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1091,6 +1094,7 @@
04344214225F0EDD003F7EC1
/* View */
=
{
isa
=
PBXGroup
;
children
=
(
C4F90D542864560B008A1E38
/* Sigin */
,
04E789DC2696E37C00A1C6D4
/* Answer */
,
04CB7E5E24AD7E8800EF6BCF
/* Barrage */
,
04357C6522699371002081C0
/* Main */
,
...
...
@@ -1920,6 +1924,15 @@
name
=
"Supporting Files"
;
sourceTree
=
"<group>"
;
};
C4F90D542864560B008A1E38
/* Sigin */
=
{
isa
=
PBXGroup
;
children
=
(
C4F90D552864560B008A1E38
/* HDSSiginVIew.m */
,
C4F90D562864560B008A1E38
/* HDSSiginVIew.h */
,
);
path
=
Sigin
;
sourceTree
=
"<group>"
;
};
DD383810264E5839006A48EE
/* SDK */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -2417,6 +2430,7 @@
04344394225F1F07003F7EC1
/* UIView+WebCache.m in Sources */
,
049FF09A225EEEA700D944C5
/* NSObject+MJClass.m in Sources */
,
04344372225F1F07003F7EC1
/* SDImageAPNGCoder.m in Sources */
,
C4F90D572864560B008A1E38
/* HDSSiginVIew.m in Sources */
,
043D4E6022D5BA3000FCDCBE
/* DWScreeningBgView.m in Sources */
,
04344370225F1F07003F7EC1
/* SDMemoryCache.m in Sources */
,
04CB7E7024AD7E8800EF6BCF
/* DWBarrageTextCell.m in Sources */
,
...
...
Demo/Demo/Classes/DWLocalPlayViewController.m
View file @
b4c4618b
...
...
@@ -41,7 +41,7 @@
return
;
}
}
self
.
downloadModel
.
randomSign
=
@{
@"seconds"
:
@[
@7
,
@18
],
@"title"
:
@"本地视频签到"
,
@"content"
:
@"触手可及斯柯达几十块的境况数据库的数据库但实际上肯德基看似简单11111双卡双待就开始江苏科技SDK手机看的点点滴滴多多"
,
@"btnText"
:
@"点击签到"
};;
[
self
.
playerView
playLocalVideo
:
self
.
downloadModel
];
/*
...
...
Demo/Demo/Classes/DWVodPlayViewController.m
View file @
b4c4618b
...
...
@@ -14,7 +14,7 @@
#import "DWNetworkMonitorViewController.h"
#import "DWScreeningListViewController.h"
#import "DWScreeningBgView.h"
#import "MJExtension.h"
typedef
enum
:
NSUInteger
{
DWVodPlayTableViewCellStyleDefault
,
DWVodPlayTableViewCellStyleChoose
,
...
...
@@ -35,7 +35,8 @@ typedef enum : NSUInteger {
@property
(
nonatomic
,
assign
)
BOOL
isLock
;
//@property (nonatomic, strong) DWPlayInfo * playInfo;
@property
(
nonatomic
,
strong
)
DWPlayInfo
*
playInfo
;
@property
(
nonatomic
,
strong
)
NSDictionary
*
signDict
;
@end
...
...
@@ -57,7 +58,7 @@ typedef enum : NSUInteger {
return
;
}
}
self
.
signDict
=
@{
@"seconds"
:
@[
@100
,
@60
,
@60
,
@120
,
@180
],
@"title"
:
@"测试随机签到"
,
@"content"
:
@"是的是的多多多多多多多吃is好滴好滴啊还是肯定会教案设计安徽师大可结案回调数据客户的家看回撒娇坎大哈数据库的好时机斯卡哈数据库回到家说不定就啊不是看都不看萨哈比"
,
@"btnText"
:
@"点击签到三生三世"
};
DWConfigurationManager
*
manager
=
[
DWConfigurationManager
sharedInstance
];
manager
.
isOpenAd
=
YES
;
if
(
manager
.
isOpenAd
)
{
...
...
@@ -76,24 +77,26 @@ typedef enum : NSUInteger {
__weak
typeof
(
self
)
weakSelf
=
self
;
DWPlayInfo
*
playInfo
=
[[
DWPlayInfo
alloc
]
initWithUserId
:[
DWConfigurationManager
sharedInstance
].
DWAccount_userId
andVideoId
:
videoId
key
:
[
DWConfigurationManager
sharedInstance
].
DWAccount_apikey
hlsSupport
:
@"1"
];
playInfo
.
timeoutSeconds
=
30
;
_playInfo
=
playInfo
;
_playInfo
.
timeoutSeconds
=
30
;
//音频 + 视频数据,这里仅做示范,可根据自己项目业务逻辑来调整
//开启授权验证功能传入
playInfo
.
verificationCode
=
[
DWConfigurationManager
sharedInstance
].
verification
;
_
playInfo
.
verificationCode
=
[
DWConfigurationManager
sharedInstance
].
verification
;
//客户端用户id,选填
// playInfo.roleId = @"";
playInfo
.
mediatype
=
@"0"
;
playInfo
.
isAllow
=
NO
;
//yes:拖拽不显示答题器
playInfo
.
finishBlock
=
^
(
DWVodVideoModel
*
vodVideo
)
{
_
playInfo
.
mediatype
=
@"0"
;
_
playInfo
.
isAllow
=
NO
;
//yes:拖拽不显示答题器
_
playInfo
.
finishBlock
=
^
(
DWVodVideoModel
*
vodVideo
)
{
NSLog
(
@"%@"
,
vodVideo
);
//下载时,保存图片,名字等数据
weakSelf
.
playerView
.
vodModel
=
weakSelf
.
vodModel
;
vodVideo
.
randomSign
=
weakSelf
.
signDict
;
[
weakSelf
.
playerView
setVodVideo
:
vodVideo
];
};
playInfo
.
errorBlock
=
^
(
NSError
*
error
)
{
_
playInfo
.
errorBlock
=
^
(
NSError
*
error
)
{
[
error
.
localizedDescription
showAlert
];
};
[
playInfo
start
];
[
_
playInfo
start
];
}
//1片头广告,2暂停广告,3片尾广告
...
...
@@ -471,6 +474,7 @@ typedef enum : NSUInteger {
[
self
.
playerView
saveSliderSchedule
];
self
.
vodModel
=
vodModel
;
self
.
signDict
=
@{
@"seconds"
:
@[
@10
,
@40
,
@80
],
@"title"
:
@"切换-->测试随机签到"
,
@"content"
:
@"是的是的多多多多多多多吃is好滴好滴啊还是肯定会教案设计安徽师大可结案回调数据客户的家看回撒娇坎大哈数据库的好时机斯卡哈数据库回到家说不定就啊不是看都不看萨哈比"
,
@"btnText"
:
@"点击签到"
};
DWConfigurationManager
*
manager
=
[
DWConfigurationManager
sharedInstance
];
if
(
manager
.
isOpenAd
)
{
//广告模式
...
...
Demo/Demo/Classes/View/Player/DWVodPlayerView.m
View file @
b4c4618b
...
...
@@ -36,6 +36,7 @@
#import "DWAnswerModel.h"
#import "MJExtension.h"
#import "DWPlayerKnowledgeView.h"
#import "HDSSiginVIew.h"
@interface
DWVodPlayerView
()
<
DWVideoPlayerDelegate
,
DWPlayerSettingViewDelegate
,
DWGifRecordFinishViewDelegate
,
DWVisitorCollectViewDelegate
,
DWExercisesAlertViewDelegate
,
DWExercisesViewDelegate
,
AVPictureInPictureControllerDelegate
,
DWVodPlayerPanGestureDelegate
,
DWBarrageManagerDelegate
,
DWBarrageBgViewDelegate
>
@property
(
nonatomic
,
strong
)
UIView
*
maskView
;
//遮罩层
...
...
@@ -248,6 +249,11 @@
@property
(
nonatomic
,
strong
)
NSIndexPath
*
indexPath
;
@property
(
nonatomic
,
strong
)
DWPlayerKnowledgeView
*
knowledgeView
;
//****************************随机签到功能******************
@property
(
nonatomic
,
strong
)
HDSSiginVIew
*
signView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
signArr
;
//签到记录
@property
(
nonatomic
,
assign
)
int
currentIndex
;
//记录角标
@end
@implementation
DWVodPlayerView
...
...
@@ -314,7 +320,8 @@ static CGFloat barrageBgHeight = 40;
self
.
isShowAd
=
NO
;
self
.
allowImpact
=
[[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"allowImpact"
]
boolValue
];
self
.
signArr
=
[
NSMutableArray
array
];
self
.
currentIndex
=
0
;
self
.
backgroundColor
=
[
UIColor
blackColor
];
[
self
initMaskView
];
...
...
@@ -466,6 +473,22 @@ static CGFloat barrageBgHeight = 40;
[
_answerView
removeFromSuperview
];
_answerView
=
nil
;
}
if
(
_signView
){
[
_signView
removeFromSuperview
];
_signView
=
nil
;
}
NSArray
*
sortArray
=
[
self
.
videoModel
.
randomSign
[
@"seconds"
]
sortedArrayUsingComparator
:
^
NSComparisonResult
(
id
obj1
,
id
obj2
)
{
if
([
obj1
floatValue
]
>
[
obj2
floatValue
])
{
return
NSOrderedDescending
;
//降序
}
else
if
([
obj1
floatValue
]
>
[
obj2
floatValue
]){
return
NSOrderedAscending
;
//升序
}
else
{
return
NSOrderedSame
;
//相等
}
}];
[
self
.
signArr
removeAllObjects
];
[
self
.
signArr
addObjectsFromArray
:
sortArray
];
self
.
currentIndex
=
0
;
[
self
.
answerArr
removeAllObjects
];
//当数组中包含video_clicker的时候才会请求答题器和知识点接口
if
([
self
.
videoModel
.
reskeys
containsObject
:
@"video_clicker"
]
||
[
self
.
videoModel
.
reskeys
containsObject
:
@"video_knowledge"
]){
...
...
@@ -509,8 +532,13 @@ static CGFloat barrageBgHeight = 40;
self
.
knowledgeBtn
.
hidden
=
YES
;
}
}
else
{
self
.
knowledgeBtn
.
hidden
=
NO
;
[
self
.
knowledgeBtn
setTitle
:
self
.
knowledgeLocalDict
[
@"name"
]
forState
:
0
];
if
(
self
.
isFull
){
self
.
knowledgeBtn
.
hidden
=
NO
;
[
self
.
knowledgeBtn
setTitle
:
self
.
knowledgeLocalDict
[
@"name"
]
forState
:
0
];
}
else
{
self
.
knowledgeBtn
.
hidden
=
YES
;
[
self
.
knowledgeBtn
setTitle
:
self
.
knowledgeLocalDict
[
@"name"
]
forState
:
0
];
}
}
}
}];
...
...
@@ -520,8 +548,24 @@ static CGFloat barrageBgHeight = 40;
-
(
void
)
playLocalVideo
:(
DWDownloadModel
*
)
downloadModel
{
self
.
videoModel
=
nil
;
if
(
_signView
){
[
_signView
removeFromSuperview
];
_signView
=
nil
;
}
self
.
currentIndex
=
0
;
self
.
downloadModel
=
downloadModel
;
NSArray
*
sortArray
=
[
self
.
downloadModel
.
randomSign
[
@"seconds"
]
sortedArrayUsingComparator
:
^
NSComparisonResult
(
id
obj1
,
id
obj2
)
{
if
([
obj1
floatValue
]
>
[
obj2
floatValue
])
{
return
NSOrderedDescending
;
//降序
}
else
if
([
obj1
floatValue
]
>
[
obj2
floatValue
]){
return
NSOrderedAscending
;
//升序
}
else
{
return
NSOrderedSame
;
//相等
}
}];
[
self
.
signArr
removeAllObjects
];
[
self
.
signArr
addObjectsFromArray
:
sortArray
];
self
.
enable
=
YES
;
self
.
readyToPlay
=
NO
;
...
...
@@ -729,6 +773,8 @@ static CGFloat barrageBgHeight = 40;
//切换视频,保存已看进度
-
(
void
)
saveSliderSchedule
{
[
self
.
signView
removeFromSuperview
];
self
.
signView
=
nil
;
[
self
writeSliderWithVideoID
:
self
.
vodModel
.
videoId
];
}
...
...
@@ -1549,7 +1595,7 @@ static CGFloat barrageBgHeight = 40;
weakSelf
.
exercisesLastScrubTime
=
-
1
;
}
if
(
_questionView
||
weakSelf
.
visitorCollectView
||
weakSelf
.
exercisesAlertView
||
weakSelf
.
exercisesView
||
_answerView
)
{
if
(
_questionView
||
weakSelf
.
visitorCollectView
||
weakSelf
.
exercisesAlertView
||
weakSelf
.
exercisesView
||
_answerView
||
_signView
)
{
return
;
}
...
...
@@ -2884,6 +2930,39 @@ static CGFloat barrageBgHeight = 40;
}
}
-
(
void
)
showSignView
:(
CGFloat
)
time
{
NSDictionary
*
dict
=
self
.
videoModel
.
randomSign
;
NSArray
*
arr
=
dict
[
@"seconds"
];
if
(
!
dict
){
dict
=
self
.
downloadModel
.
randomSign
;
arr
=
dict
[
@"seconds"
];
}
if
(
_signView
){
return
;
}
for
(
NSNumber
*
second
in
self
.
signArr
)
{
if
([
second
intValue
]
<=
(
NSInteger
)
time
)
{
self
.
currentIndex
++
;
[
self
.
signArr
removeObjectAtIndex
:
0
];
[
self
sendWindowsFuncNotification
:
NO
];
[
self
destroyFuncTimer
];
[
self
pause
];
//暂停
if
(
_signView
||
_answerView
||
self
.
exercisesAlertView
||
self
.
exercisesView
||
_questionView
||
_visitorCollectView
){
return
;
}
_signView
=
[
HDSSiginVIew
new
];
[
_signView
showSiginViewWithParam
:
dict
index
:
self
.
currentIndex
];
@weakify
(
self
);
self
.
signView
.
signBLock
=
^
{
//继续播放
@strongify
(
self
);
[
self
resumeVideoPlay
];
self
.
signView
=
nil
;
};
break
;
}
}
}
-
(
void
)
resumeVideoPlay
{
[
self
play
];
//播放
...
...
@@ -4021,8 +4100,6 @@ static CGFloat barrageBgHeight = 40;
[
self
.
subtitleView
setSubtitleWithTime
:
time
];
}
//答题器功能
// [self showAswerView:time];
//问答功能
[
self
showQuestionsView
:
time
];
...
...
@@ -4036,7 +4113,7 @@ static CGFloat barrageBgHeight = 40;
[
self
showImpactView
:
time
];
[
self
showAswerView
:
time
];
[
self
showSignView
:
time
];
//随机签到
self
.
exercisesLastScrubTime
=
time
;
//拖拽时,禁止刷新进度信息
...
...
@@ -4114,7 +4191,7 @@ static CGFloat barrageBgHeight = 40;
return
;
}
if
(
_questionView
||
self
.
visitorCollectView
||
self
.
exercisesAlertView
||
self
.
exercisesView
||
_answerView
)
{
if
(
_questionView
||
self
.
visitorCollectView
||
self
.
exercisesAlertView
||
self
.
exercisesView
||
_answerView
||
_signView
)
{
return
;
}
...
...
@@ -4972,7 +5049,7 @@ static CGFloat barrageBgHeight = 40;
{
if
(
!
_speedArray
)
{
_speedArray
=
[[
NSMutableArray
alloc
]
init
];
NSArray
*
titles
=
@[
@"0.5X"
,
@"1.0X"
,
@"1.5X"
,
@"2.0X"
];
NSArray
*
titles
=
@[
@"0.5X"
,
@"1.0X"
,
@"1.5X"
,
@"2.0X"
,
@"2.5X"
];
[
titles
enumerateObjectsUsingBlock
:
^
(
id
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
DWTableChooseModel
*
chooseModel
=
[[
DWTableChooseModel
alloc
]
init
];
chooseModel
.
title
=
(
NSString
*
)
obj
;
...
...
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.h
0 → 100644
View file @
b4c4618b
//
// HDSSiginVIew.h
// Demo
//
// Created by gw on 2022/6/15.
// Copyright © 2022 com.bokecc.www. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef
void
(
^
HDSSignBlock
)(
void
);
@interface
HDSSiginVIew
:
UIView
-
(
void
)
showSiginViewWithParam
:(
NSDictionary
*
)
signDict
index
:(
int
)
index
;
@property
(
nonatomic
,
copy
)
HDSSignBlock
signBLock
;
@end
NS_ASSUME_NONNULL_END
Demo/Demo/Classes/View/Sigin/HDSSiginVIew.m
0 → 100644
View file @
b4c4618b
//
// HDSSiginVIew.m
// Demo
//
// Created by gw on 2022/6/15.
// Copyright © 2022 com.bokecc.www. All rights reserved.
//
#import "HDSSiginVIew.h"
#define ScreenW [UIScreen mainScreen].bounds.size.width
#define ScreenH [UIScreen mainScreen].bounds.size.height
#define iPhoneX (((int)((ScreenH/ScreenW)*100) == 216)?YES:NO)
@interface
HDSSiginVIew
()
@property
(
nonatomic
,
strong
)
UIImageView
*
topImage
;
@property
(
nonatomic
,
strong
)
UIView
*
whiteCenterView
;
@property
(
nonatomic
,
strong
)
UILabel
*
titleLabel
;
@property
(
nonatomic
,
strong
)
UILabel
*
contentView
;
@property
(
nonatomic
,
strong
)
UIButton
*
signinBtn
;
@property
(
nonatomic
,
assign
)
BOOL
isLandscape
;
//是否是横屏
@property
(
nonatomic
,
assign
)
CGFloat
DWHeight
;
//播放器高度
@property
(
nonatomic
,
strong
)
UIButton
*
markBtn
;
@property
(
nonatomic
,
copy
)
NSString
*
contentStr
;
@end
@implementation
HDSSiginVIew
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
{
if
(
self
==
[
super
initWithFrame
:
frame
]){
self
.
backgroundColor
=
ColorFrom16A
(
0x000000
,
0
.
5
);
CGSize
viewSize
=
CGSizeZero
;
if
(
@available
(
iOS
11
.
0
,
*
))
{
CGFloat
a
=
[[
UIApplication
sharedApplication
]
delegate
].
window
.
safeAreaInsets
.
bottom
;
if
(
a
>
0
)
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
)
+
64
);
}
else
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
));
}
}
else
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
));
}
_DWHeight
=
viewSize
.
height
;
// 判断横屏
if
([
UIApplication
sharedApplication
].
statusBarOrientation
==
UIDeviceOrientationLandscapeRight
||
[
UIApplication
sharedApplication
].
statusBarOrientation
==
UIDeviceOrientationLandscapeLeft
)
{
//当前横屏
_isLandscape
=
YES
;
}
else
{
//当前竖屏
_isLandscape
=
NO
;
}
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
deviceOrientationChangeNotification
)
name
:
UIDeviceOrientationDidChangeNotification
object
:
nil
];
if
(
_isLandscape
){
self
.
frame
=
CGRectMake
(
0
,
0
,
ScreenWidth
,
ScreenHeight
);
}
else
{
self
.
frame
=
CGRectMake
(
0
,
0
,
ScreenWidth
,
_DWHeight
);
}
[[
UIApplication
sharedApplication
].
keyWindow
addSubview
:
self
];
}
return
self
;
}
-
(
void
)
deviceOrientationChangeNotification
{
CGSize
viewSize
=
CGSizeZero
;
if
(
@available
(
iOS
11
.
0
,
*
))
{
CGFloat
a
=
[[
UIApplication
sharedApplication
]
delegate
].
window
.
safeAreaInsets
.
bottom
;
if
(
a
>
0
)
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
)
+
64
);
}
else
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
));
}
}
else
{
viewSize
=
CGSizeMake
(
ScreenWidth
,
ScaleHeight
(
ScreenWidth
,
375
/
211
.
0
));
}
_DWHeight
=
viewSize
.
height
;
UIDeviceOrientation
orientation
=
[
UIDevice
currentDevice
].
orientation
;
UIInterfaceOrientation
interfaceOrientation
=
(
UIInterfaceOrientation
)
orientation
;
switch
(
interfaceOrientation
)
{
case
UIInterfaceOrientationPortrait
:{
// NSLog(@"================ 竖屏");
_isLandscape
=
NO
;
[
self
updateLayout
];
break
;
}
case
UIInterfaceOrientationLandscapeLeft
:{
// NSLog(@"++++++ 横屏");
_isLandscape
=
YES
;
[
self
updateLayout
];
break
;
}
case
UIInterfaceOrientationLandscapeRight
:{
// NSLog(@"----------- 横屏");
_isLandscape
=
YES
;
[
self
updateLayout
];
break
;
}
default:
break
;
}
}
-
(
void
)
showSiginViewWithParam
:(
NSDictionary
*
)
signDict
index
:(
int
)
index
{
[
self
setupViewWithParam
:
signDict
index
:
index
];
}
-
(
void
)
setupViewWithParam
:(
NSDictionary
*
)
dict
index
:(
int
)
index
{
_whiteCenterView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
375
,
100
)];
_whiteCenterView
.
layer
.
cornerRadius
=
5
;
_whiteCenterView
.
layer
.
backgroundColor
=
UIColor
.
whiteColor
.
CGColor
;
_whiteCenterView
.
center
=
self
.
center
;
[
self
addSubview
:
_whiteCenterView
];
_markBtn
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
[
_markBtn
setImage
:[
UIImage
imageNamed
:
@"sign_bgView_icon"
]
forState
:
0
];
_markBtn
.
frame
=
CGRectMake
(
0
,
0
,
30
,
30
);
[
_markBtn
setTitleColor
:
ColorFrom16A
(
0x666666
,
1
)
forState
:
0
];
_markBtn
.
titleLabel
.
font
=
DWFont
(
12
);
[
_markBtn
setTitle
:[
NSString
stringWithFormat
:
@"%d"
,
index
]
forState
:
0
];
[
_markBtn
setTitleEdgeInsets
:
UIEdgeInsetsMake
(
-
8
,
-
40
,
0
,
0
)];
[
_whiteCenterView
addSubview
:
_markBtn
];
_topImage
=
[
UIImageView
new
];
_topImage
.
image
=
[
UIImage
imageNamed
:
@"sigin_icon"
];
[
_whiteCenterView
addSubview
:
_topImage
];
[
_topImage
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
_whiteCenterView
.
mas_centerX
);
make
.
top
.
equalTo
(
_whiteCenterView
.
mas_top
).
offset
(
-
39
);
make
.
width
.
equalTo
(
@100
);
make
.
height
.
equalTo
(
@70
);
}];
_titleLabel
=
[
UILabel
new
];
_titleLabel
.
textColor
=
UIColor
.
blackColor
;
_titleLabel
.
font
=
[
UIFont
boldSystemFontOfSize
:
16
];
_titleLabel
.
textAlignment
=
1
;
_titleLabel
.
text
=
dict
[
@"title"
];
[
_whiteCenterView
addSubview
:
_titleLabel
];
[
_titleLabel
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
_topImage
.
mas_bottom
).
offset
(
8
);
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
30
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
30
);
make
.
height
.
equalTo
(
@16
);
}];
_contentView
=
[
UILabel
new
];
NSString
*
content
=
dict
[
@"content"
];
_contentStr
=
content
;
_contentView
.
text
=
content
;
_contentView
.
textColor
=
ColorFrom16A
(
0x666666
,
1
);
_contentView
.
font
=
DWFont
(
12
);
[
_whiteCenterView
addSubview
:
_contentView
];
[
_contentView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
_isLandscape
){
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
30
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
30
);
_contentView
.
numberOfLines
=
0
;
}
else
{
_contentView
.
numberOfLines
=
2
;
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
10
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
10
);
make
.
height
.
equalTo
(
@36
);
}
make
.
top
.
equalTo
(
_titleLabel
.
mas_bottom
).
offset
(
8
);
// make.height.equalTo(@([DWTools widthWithHeight:375 andFont:[UIFont systemFontOfSize:12] andLabelText:content].height+20));
}];
_signinBtn
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
[
_signinBtn
setTitle
:
dict
[
@"btnText"
]
forState
:
0
];
_signinBtn
.
layer
.
cornerRadius
=
4
;
_signinBtn
.
layer
.
masksToBounds
=
YES
;
_signinBtn
.
backgroundColor
=
ColorFrom16A
(
0xff842f
,
1
);
[
_signinBtn
addTarget
:
self
action
:
@selector
(
handleSignBtn
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_whiteCenterView
addSubview
:
_signinBtn
];
[
_signinBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
30
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
30
);
make
.
height
.
equalTo
(
@40
);
make
.
bottom
.
equalTo
(
_whiteCenterView
).
offset
(
-
8
);
}];
CGFloat
height
=
39
+
32
+
56
+
[
DWTools
widthWithHeight
:
375
andFont
:[
UIFont
systemFontOfSize
:
12
]
andLabelText
:
content
].
height
;
if
(
self
.
isLandscape
){
_whiteCenterView
.
frame
=
CGRectMake
(
0
,
0
,
375
,
height
+
12
);
_whiteCenterView
.
center
=
self
.
center
;
}
else
{
if
(
iPhoneX
){
_whiteCenterView
.
frame
=
CGRectMake
(
20
,
70
,
ScreenWidth
-
40
,
39
+
32
+
56
+
20
+
12
);
}
else
{
_whiteCenterView
.
frame
=
CGRectMake
(
20
,
50
,
ScreenWidth
-
40
,
39
+
32
+
56
+
20
+
12
);
}
}
}
-
(
void
)
handleSignBtn
{
[
self
removeFromSuperview
];
if
(
self
.
signBLock
){
self
.
signBLock
();
}
}
-
(
void
)
updateLayout
{
if
(
_isLandscape
){
self
.
frame
=
CGRectMake
(
0
,
0
,
ScreenWidth
,
ScreenHeight
);
}
else
{
self
.
frame
=
CGRectMake
(
0
,
0
,
ScreenWidth
,
_DWHeight
);
}
[
_contentView
mas_remakeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
_isLandscape
){
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
30
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
30
);
_contentView
.
numberOfLines
=
0
;
}
else
{
_contentView
.
numberOfLines
=
2
;
make
.
left
.
equalTo
(
_whiteCenterView
).
offset
(
10
);
make
.
right
.
equalTo
(
_whiteCenterView
).
offset
(
-
10
);
make
.
height
.
equalTo
(
@36
);
}
make
.
top
.
equalTo
(
_titleLabel
.
mas_bottom
).
offset
(
8
);
}];
CGFloat
height
=
39
+
32
+
56
+
[
DWTools
widthWithHeight
:
375
andFont
:[
UIFont
systemFontOfSize
:
12
]
andLabelText
:
_contentStr
].
height
;
if
(
self
.
isLandscape
){
_whiteCenterView
.
frame
=
CGRectMake
(
0
,
0
,
375
,
height
+
12
);
_whiteCenterView
.
center
=
self
.
center
;
}
else
{
if
(
iPhoneX
){
_whiteCenterView
.
frame
=
CGRectMake
(
20
,
70
,
ScreenWidth
-
40
,
39
+
32
+
56
+
20
+
12
);
}
else
{
_whiteCenterView
.
frame
=
CGRectMake
(
20
,
50
,
ScreenWidth
-
40
,
39
+
32
+
56
+
20
+
12
);
}
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code