Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e39a6907
authored
Oct 09, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整扫码界面
parent
42a6a49b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
MRFramework/MRFramework/UIControls/Scanning/Interface/MRScanningLineView.swift
+5
-6
MRFramework/MRFramework/UIControls/Scanning/MRScanningProtocol.swift
+14
-2
No files found.
MRFramework/MRFramework/UIControls/Scanning/Interface/MRScanningLineView.swift
View file @
e39a6907
...
...
@@ -21,9 +21,6 @@ public final class MRScanningLineView: UIView {
}
}
// 2端透明比例
private
let
opacityRatio
:
Float
=
0.25
private
let
gradientLayer
=
CAGradientLayer
()
public
override
init
(
frame
:
CGRect
)
{
...
...
@@ -39,9 +36,11 @@ public final class MRScanningLineView: UIView {
extension
MRScanningLineView
{
private
func
setupGradientLayer
()
{
gradientLayer
.
frame
=
layer
.
bounds
gradientLayer
.
config
(
colors
:
[
.
init
(
color
:
.
clear
,
location
:
0
),
.
init
(
color
:
color
,
location
:
1
-
2*
opacityRatio
),
.
init
(
color
:
.
clear
,
location
:
1
)],
gradientLayer
.
config
(
colors
:
[
.
init
(
color
:
color
.
withAlphaComponent
(
0
),
location
:
0
),
.
init
(
color
:
color
.
withAlphaComponent
(
0.3
),
location
:
0.1
),
.
init
(
color
:
color
,
location
:
0.5
),
.
init
(
color
:
color
.
withAlphaComponent
(
0.3
),
location
:
0.9
),
.
init
(
color
:
color
.
withAlphaComponent
(
0
),
location
:
1
)],
direction
:
.
horizontal
(
1
))
layer
.
addSublayer
(
gradientLayer
)
}
...
...
MRFramework/MRFramework/UIControls/Scanning/MRScanningProtocol.swift
View file @
e39a6907
...
...
@@ -32,6 +32,7 @@ private let innerRectViewTag = 99033
private
let
lineViewTag
=
99034
private
var
managerStoreKey
=
"MRScanningProtocolManager"
private
var
privateInterfaceTypeKey
=
"MRScanInterfaceType"
public
protocol
MRScanningProtocol
:
NSObject
{
typealias
InterfaceSetting
=
(
_
shadowView
:
MRScanningShadowView
,
_
innerView
:
MRScanningRectLineView
,
_
scanLineView
:
MRScanningLineView
)
->
Void
...
...
@@ -60,6 +61,10 @@ extension MRScanningProtocol where Self: UIViewController {
public
var
scanLineView
:
MRScanningLineView
?
{
return
view
.
viewWithTag
(
lineViewTag
)
as?
MRScanningLineView
}
public
var
currentInterfaceTypeConfig
:
(
scanningRect
:
CGRect
,
innerRect
:
CGRect
)?
{
return
objc_getAssociatedObject
(
self
,
&
privateInterfaceTypeKey
)
as
?
(
scanningRect
:
CGRect
,
innerRect
:
CGRect
)
}
}
extension
MRScanningProtocol
where
Self
:
UIViewController
{
...
...
@@ -81,6 +86,7 @@ extension MRScanningProtocol where Self: UIViewController {
public
func
layoutScanningInterface
(
_
type
:
ScanningInterfaceType
,
in
rect
:
CGRect
)
{
let
config
=
type
.
config
(
in
:
rect
)
setInterfaceTypeConfig
(
config
)
shadowView
?
.
frame
=
CGRect
(
origin
:
CGPoint
.
zero
,
size
:
rect
.
size
)
shadowView
?
.
interestFrame
=
config
.
innerRect
rectLineView
?
.
frame
=
config
.
innerRect
...
...
@@ -96,8 +102,8 @@ extension MRScanningProtocol where Self: UIViewController {
}
public
func
startScanningAnimation
()
{
if
let
lineView
=
scanLineView
,
let
rectHeight
=
rectLineView
?
.
frame
.
height
,
let
cornerHeight
=
rectLineView
?
.
cornerLineWidth
{
if
let
lineView
=
scanLineView
,
let
rectHeight
=
currentInterfaceTypeConfig
?
.
innerRect
.
height
,
let
cornerHeight
=
rectLineView
?
.
cornerLineWidth
{
let
distance
=
rectHeight
-
cornerHeight
-
lineView
.
frame
.
height
let
animation
=
CABasicAnimation
()
...
...
@@ -123,3 +129,9 @@ extension MRScanningProtocol where Self: UIViewController {
scanLineView
?
.
isHidden
=
hide
}
}
extension
MRScanningProtocol
where
Self
:
UIViewController
{
private
func
setInterfaceTypeConfig
(
_
config
:
(
scanningRect
:
CGRect
,
innerRect
:
CGRect
))
{
objc_setAssociatedObject
(
self
,
&
privateInterfaceTypeKey
,
config
,
.
OBJC_ASSOCIATION_COPY_NONATOMIC
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment